React useContext() hook introduction 🧗‍♂️

Поделиться
HTML-код
  • Опубликовано: 4 июл 2024
  • #reactjs #tutorial #course
    00:00:00 intro
    00:00:13 setup
    00:04:39 props
    00:06:01 prop drilling
    00:06:17 useContext
    00:06:27 Provider Component
    00:08:28 Consumer Components
    00:10:11 multiple consumer components
    00:11:10 conclusion
    // useContext() = React Hook that allows you to share values
    // between multiple levels of components
    // without passing props through each level

Комментарии • 82

  • @BroCodez
    @BroCodez  5 месяцев назад +14

    // useContext() = React Hook that allows you to share values
    // between multiple levels of components
    // without passing props through each level
    // PROVIDER COMPONENT
    // 1. import {createContext} from 'react';
    // 2. export const MyContext = createContext();
    // 3.
    //
    //
    // CONSUMER COMPONENTS
    // 1. import React, { useContext } from 'react';
    // import { MyContext } from './ComponentA';
    // 2. const value = useContext(MyContext);
    // ---------- CSS ----------
    .box{
    border: 3px solid;
    padding: 25px;
    }
    // ---------- App ----------
    import ComponentA from './ComponentA.jsx';
    import React from 'react';
    function App() {
    return();
    }
    export default App;
    // ---------- ComponentA ----------
    import React, {useState, createContext} from 'react';
    import ComponentB from './ComponentB.jsx';
    export const UserContext = createContext();
    function ComponentA(){
    const [user, setUser] = useState("BroCode");
    return(

    ComponentA
    {`Hello ${user}`}




    );
    }
    export default ComponentA
    // ---------- ComponentB ----------
    import ComponentC from './ComponentC.jsx';
    function ComponentB(){
    return(

    ComponentB


    );
    }
    export default ComponentB
    // ---------- ComponentC ----------
    import ComponentD from './ComponentD.jsx';
    function ComponentC(){
    return(

    ComponentC


    );
    }
    export default ComponentC
    // ---------- ComponentD ----------
    import React, {useContext} from 'react';
    import {UserContext} from './ComponentA.jsx';
    function ComponentD(){
    const user = useContext(UserContext);
    return(

    ComponentD
    {`Bye ${user}`}

    );
    }
    export default ComponentD

    • @jithan977
      @jithan977 5 месяцев назад +1

      bro plz upload every day and always thankful for u

    • @rayyanabdulwajid7681
      @rayyanabdulwajid7681 5 месяцев назад

      Make a crud todo in vanilla javascript where we can enter more than 1 value inside a form.

    • @lonelydevilcreations
      @lonelydevilcreations 5 месяцев назад

      Please make redux and context API videos

    • @-_SleepAndEat_-
      @-_SleepAndEat_- 2 месяца назад

      Bro can you do Kali Linux ?

  • @ChucklesMcGee780
    @ChucklesMcGee780 Месяц назад +3

    thanks for making this. I've been so confused by useContext, after a course and quite a few videos, until i found this.

  • @a13519
    @a13519 4 месяца назад +4

    The best explaination in youtube about context

  • @valerylouis6747
    @valerylouis6747 5 месяцев назад +3

    Such a simple and easy to understand tutorial. I've watched all the tutorials he has on react, waiting on him to release new ones

  • @daverzeacademy
    @daverzeacademy День назад

    I don't know how you make complicated concepts look so simple.
    I hope you see this comment one day. I just want to say thank you ❣️

  • @MirzaMesinovic
    @MirzaMesinovic 3 месяца назад

    Absolutely amazing tutorial. Impossible to not understand. Thanks!

  • @JamesTheSuperDev
    @JamesTheSuperDev Месяц назад

    Short and sweet. Exactly what I have been looking for.

  • @ronjohnson123
    @ronjohnson123 2 месяца назад +5

    What a great explanation! Watched numerous videos before this on useContext & still struggled to understand. I then watch one of your videos & instantly understood! Great work

  • @sanjibkarki9000
    @sanjibkarki9000 20 дней назад

    Thank you for simplifying this with very clear example.

  • @java_learn6447
    @java_learn6447 5 месяцев назад +3

    Amazing lecture

  • @hananfadah
    @hananfadah 5 месяцев назад

    Wow thanks a lot! What a great explanation. Truly appreciate your effort.

  • @ttsl8922
    @ttsl8922 3 месяца назад

    the example is intuitive and easy to understand. ty

  • @aswin9750
    @aswin9750 22 дня назад

    Now i understand useContext is a very simple concept. Thank you for you explanation

  • @remember.772
    @remember.772 Месяц назад

    I subscribed ur channel today cause u deserve it ,u explain with simple terms that's what we need, for juniors first they should understand how it works then they will work with confident

  • @shubhamsonar5689
    @shubhamsonar5689 5 месяцев назад

    love you bro such a super duper easy to understand 🙌

  • @mjylove2
    @mjylove2 17 дней назад

    such a amazing explanation

  • @MyCodeJourney-wv2oc
    @MyCodeJourney-wv2oc 11 дней назад

    thank you man, so clear and enjoyable
    😊😊😊❤❤❤

  • @rohansaka2808
    @rohansaka2808 19 дней назад

    Your voice is rock solid like a Hollywood hero indeed you are my technical hero and guru

  • @razkoreakpop9805
    @razkoreakpop9805 5 месяцев назад

    Thank you for uploading video ❤

  • @monmaka
    @monmaka 5 месяцев назад +1

    I finally understand it. Thanks bro

  • @ilhamnurutomo6930
    @ilhamnurutomo6930 2 месяца назад

    thanks, great explanation

  • @sebastianlozano7707
    @sebastianlozano7707 5 месяцев назад

    Most of what I know about Javascript is thanks to you! Thanks Bro Code

  • @zainashraf259
    @zainashraf259 28 дней назад

    Great Explaination.. And Concise also... Liked...

  • @shreehari2589
    @shreehari2589 5 месяцев назад +4

    Yeah no one could have explained it better than you, I hope you will release full react course soon, eagerly waiting for it

  • @lateefmushtaq6059
    @lateefmushtaq6059 27 дней назад

    The best explaination fro useContext, (I came from udemy course, then few other videos where they explain it as a big thing ). Thankyou :)

  • @topvibe952
    @topvibe952 Месяц назад

    Best Explanation 🤝❤❤

  • @animatsuki5345
    @animatsuki5345 3 месяца назад

    really cool! thanks man! yay

  • @bmwmotorbikesdaily
    @bmwmotorbikesdaily 3 месяца назад

    Well explained keep it up!

  • @ShashankJ04
    @ShashankJ04 5 месяцев назад

    Swear to god I have all notifications on RUclips but everytime u upload a new video I get no notification. Love your videos though!! keep on going.

  • @milad8030
    @milad8030 3 месяца назад

    I saw different video, but you are better than those. you are not in a rush, explain why we need what. thank you

  • @Comedy_Center12
    @Comedy_Center12 8 дней назад

    Excellent

  • @obafemielijah2610
    @obafemielijah2610 23 дня назад

    this is a great turtoria

  • @BishanTamang-rk5ji
    @BishanTamang-rk5ji 5 месяцев назад +2

    Make 2024 Java course love from Nepal ♥️💓

  • @user-cx2xx1cx1s
    @user-cx2xx1cx1s 3 дня назад

    It's the best video i have ever seen

  • @HarshithramSundararaman
    @HarshithramSundararaman 5 месяцев назад

    youre videos are great!

  • @pastori2672
    @pastori2672 5 месяцев назад

    i swear everytime im concerned about a concept you make a video about it

  • @valerylouis6747
    @valerylouis6747 5 месяцев назад

    I'm bout to watch this tutorial today. Anything from bro code, I know it's good

  • @THE_UNITED_STATES_OF_AMERICA51
    @THE_UNITED_STATES_OF_AMERICA51 5 месяцев назад +12

    You're trying so hard why don't you enable funds in your videos you saves a lot of our money why don't you just benefit a little bit

  • @abhishekjaiswar5182
    @abhishekjaiswar5182 2 месяца назад

    Finally I got it...❤

  • @available2574
    @available2574 5 месяцев назад

    Bro you are hero...

  • @razkoreakpop9805
    @razkoreakpop9805 5 месяцев назад +1

    Your the best

  • @pratyushkiran8654
    @pratyushkiran8654 5 месяцев назад

    Uff ! That was easy 🔥🔥

  • @DMZT_dhruv
    @DMZT_dhruv 5 месяцев назад

    you can use eslint react extension
    for typing react code faster

  • @ayeshaawan-fq3on
    @ayeshaawan-fq3on День назад

    nice

  • @user-ur3io2ny2j
    @user-ur3io2ny2j 3 месяца назад

    Please continue teaching react.. upload new video you are expert in this💔

  • @rishabhkedia9304
    @rishabhkedia9304 5 месяцев назад

    Please make Reactjs projects as well

  • @KingOfMadnesss
    @KingOfMadnesss 5 месяцев назад +1

    Day 1 of asking for an sfml full course (after your done with this course)

  • @TheMarketingMan4U
    @TheMarketingMan4U 19 дней назад +1

    Hi,
    U wrapped using provider component B in Component A but u why didn't u do the same for component D or C

  • @togya4
    @togya4 5 месяцев назад

    I wish u talked about it earlier cuz 6 months ago i was so lost ):

  • @sfg-2310
    @sfg-2310 5 месяцев назад +1

    thanks for explanation, but does needs to have 'user={user}' for useContext to work?

    • @BroCodez
      @BroCodez  5 месяцев назад +2

      You can remove user={user}, I forgot to do that in the demo

    • @sfg-2310
      @sfg-2310 5 месяцев назад

      @@BroCodez thank you for letting me know ❤❤

  • @DeadEnd_579
    @DeadEnd_579 5 месяцев назад

    Hey can u continue Data Structures and Algorithms Playlist on

  • @xySaad
    @xySaad 28 дней назад +1

    Why you never use auto complete?

  • @lonelydevilcreations
    @lonelydevilcreations 5 месяцев назад

    Please create redux and context API tutorial

  • @arshadahamed988
    @arshadahamed988 Месяц назад

    Can we have more values in single usecontext hook??

  • @natnaelabebe7397
    @natnaelabebe7397 2 месяца назад

    If anything unclear about any programming language headover brocode, then he will fix it it is his default behavior

  • @Nova_Software
    @Nova_Software 5 месяцев назад

    Day 1 of asking for a typescript tutorial, a c# with xaml tutorial and a Pygame tutorial

  • @nebojsaknezevic6053
    @nebojsaknezevic6053 Месяц назад

    Can it work in reverse? Make component C provider and then have componentA consumer?

  • @ahmadyakubuahmad7626
    @ahmadyakubuahmad7626 5 месяцев назад +1

    Bro we want to see your face and say Thank you!

    • @shreehari2589
      @shreehari2589 5 месяцев назад +1

      You can see him on twitch

    • @smithclash2898
      @smithclash2898 5 месяцев назад

      ​​@@shreehari2589what's his twitch Id?

  • @nesa6582
    @nesa6582 Месяц назад

    Naming variable UserContext was super confusing. :D

  • @abdullahabada2222
    @abdullahabada2222 18 дней назад

    Can i use usecontext for the same level for component that component a , b , c, d at the same degree of level not one is parent or child to other

  • @NathanWondwossen
    @NathanWondwossen 7 дней назад

    Can you please make a how to redirect to another page tutorial please respond 🙏🙏🙏

  • @raitaskeen
    @raitaskeen 5 месяцев назад

    Bro can u make a lecture on RUST...!

  • @santoshchulakimath
    @santoshchulakimath 3 месяца назад

    6:39 for my reference p1-p2

  • @sunilmehta5237
    @sunilmehta5237 4 месяца назад

    but how does a UserContext know that it has to provide a User data, is it by naming ? Please can someone answer this ? The reason I am asking by your example is what if I want to create this context a standalone JS class.

  • @RhemaOshogwe
    @RhemaOshogwe 5 месяцев назад

    Please I need help,
    I'm using php(xampp)
    I can't find the php.exe, I've deleted and reinstalled many times I still can't find it, I just need to know if I can use PHP in vscode without it?

    • @RhemaOshogwe
      @RhemaOshogwe 5 месяцев назад

      The same error it showed on your vscode when starting PHP that's what it's still showing in my own, but I cant find the php.exe

  • @hashirowais6475
    @hashirowais6475 5 месяцев назад

    how many videos are left till this series is over?

    • @BroCodez
      @BroCodez  5 месяцев назад +1

      Why, do you not like it?

    • @hashirowais6475
      @hashirowais6475 5 месяцев назад +1

      @@BroCodez No I love it. I just want to know much is left before I can start using react to create my own applications :)

  • @ish7862
    @ish7862 5 месяцев назад +1

    🫡🫡🫡

  • @capslock3250
    @capslock3250 Месяц назад

    Personally, I find useContext to be the most confusing hook.