React useContext() hook introduction 🧗‍♂️

Поделиться
HTML-код
  • Опубликовано: 3 окт 2024

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

  • @BroCodez
    @BroCodez  8 месяцев назад +23

    // 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

    • @Harry99-m8i
      @Harry99-m8i 8 месяцев назад +1

      bro plz upload every day and always thankful for u

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

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

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

      Please make redux and context API videos

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

      Bro can you do Kali Linux ?

  • @ronjohnson123
    @ronjohnson123 6 месяцев назад +18

    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

  • @a13519
    @a13519 7 месяцев назад +10

    The best explaination in youtube about context

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

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

  • @valerylouis6747
    @valerylouis6747 8 месяцев назад +6

    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

  • @jacksparrow694
    @jacksparrow694 10 дней назад

    Really the Best explaination of usecontext in youtube❤

  • @victoroluwatobi1531
    @victoroluwatobi1531 16 дней назад

    This is the best explanation so far, easy to comprend. You just gained a subscriber ❤🎉

  • @timid-techie
    @timid-techie 2 месяца назад +1

    I literally struggled with this concept before now, thanks bro for this example. ❤❤❤❤

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

    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

  • @baidris
    @baidris 15 дней назад

    Best explanation of Context React, Thank you.

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

    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 ❣️

  • @shreehari2589
    @shreehari2589 8 месяцев назад +3

    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 3 месяца назад

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

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

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

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

    I spent a whole week on the Context API, and you explained it in 11 minutes.

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

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

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

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

  • @parsabordbar9844
    @parsabordbar9844 26 дней назад

    Great Job and quick refresher for me thank you man!

  • @GN0AGT
    @GN0AGT 8 месяцев назад +20

    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

  • @AmswonAbrahamDeSodanoDorsainvi
    @AmswonAbrahamDeSodanoDorsainvi Месяц назад +1

    I do really Love this guy. You do know how to make people understand. You are a life savior Bro May God Jesus Christ bless you

  • @millad90s
    @millad90s 6 месяцев назад

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

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

    Absolutely amazing tutorial. Impossible to not understand. Thanks!

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

    Thank you for simplifying this with very clear example.

  • @jawad_youtube
    @jawad_youtube Месяц назад +1

    short, simple, precise

  • @monmaka
    @monmaka 8 месяцев назад +3

    I finally understand it. Thanks bro

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

    It's the best video i have ever seen

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

    Amazing lecture

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

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

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

    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.

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

    That's a great explanation‚ thank you so useful

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

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

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

    the example is intuitive and easy to understand. ty

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

    Best Explanation 🤝❤❤

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

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

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

    such a amazing explanation

  • @MyCodeJourney-wv2oc
    @MyCodeJourney-wv2oc 3 месяца назад

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

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

    love you bro such a super duper easy to understand 🙌

  • @PraveenkumarMahalingam
    @PraveenkumarMahalingam 15 дней назад

    It is very easy to understand 🎉

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

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

  • @syedmajid3202
    @syedmajid3202 14 дней назад

    Thanks for video!

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

    Excellent

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

    Make 2024 Java course love from Nepal ♥️💓

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

    this is a great turtoria

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

    i just became a fan bro. very nice

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

    Your the best

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

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

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

    Thank you for uploading video ❤

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

    you can use eslint react extension
    for typing react code faster

  • @abhishekjaiswar-n3r
    @abhishekjaiswar-n3r 5 месяцев назад

    Finally I got it...❤

  • @Itsme-o3v
    @Itsme-o3v 6 месяцев назад

    Well explained keep it up!

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

    thanks, great explanation

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

    really cool! thanks man! yay

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

    youre videos are great!

  • @otabekmadaminov-z2i
    @otabekmadaminov-z2i 11 дней назад

    Thank you bro

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

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

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

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

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

      @@BroCodez thank you for letting me know ❤❤

  • @TheMarketingMan4U
    @TheMarketingMan4U 3 месяца назад +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

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

    🧡💜💚 thank u

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

    Bro you are hero...

  • @ayeshaawan-fq3on
    @ayeshaawan-fq3on 3 месяца назад

    nice

  • @TibaFallah
    @TibaFallah 6 месяцев назад

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

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

    Bro Code is perfect Good

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

    Please make Reactjs projects as well

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

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

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

    Uff ! That was easy 🔥🔥

  • @xySaad
    @xySaad 3 месяца назад +1

    Why you never use auto complete?

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

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

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

    Thank you bro code

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

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

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

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

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

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

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

      You can see him on twitch

    • @MiniSmith998
      @MiniSmith998 8 месяцев назад

      ​​@@shreehari2589what's his twitch Id?

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

    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.

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

    Naming variable UserContext was super confusing. :D

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

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

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

    please make a video for nextjs

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

    Bro code can you please upload redux series as well.

  • @СергейИванченков-ДляСвоих

    Can i update the value in context from component D so that all consumers would get updated and rerendered new value? I have sibling components, and i need to have one sibling update value in contex so that my other sibling recieved new value.

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

    Hey can u continue Data Structures and Algorithms Playlist on

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

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

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

    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

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

    Can we have more values in single usecontext hook??

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

    6:39 for my reference p1-p2

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

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

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

    Please create redux and context API tutorial

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

    how many videos are left till this series is over?

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

      Why, do you not like it?

    • @hashirowais6475
      @hashirowais6475 8 месяцев назад +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 :)

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

    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 8 месяцев назад

      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

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

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

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

    🫡🫡🫡