React State Management using Context API (useContext + useReducer Hooks = Magic 💥)

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024

ความคิดเห็น • 107

  • @the_full_stack_junkie
    @the_full_stack_junkie  4 ปีที่แล้ว +20

    GitHub Links To Coding Examples:😎
    useReducer: github.com/LloydJanseVanRensburg/useReducer-Explaination
    useContext: github.com/LloydJanseVanRensburg/useContent-Hooks-Explanation
    Combined Todo List Project: github.com/LloydJanseVanRensburg/Todo-List-Context-Project-
    Going to make a similar video using Redux!

  • @krishnarajagopal1964
    @krishnarajagopal1964 8 หลายเดือนก่อน +1

    By far the best video I have seen on this topic, clear and concise.
    one small suggestion is that using a non-mechanical keyboard would help in hearing the voice much more clearly.

  • @jamesbest2221
    @jamesbest2221 3 ปีที่แล้ว +27

    I’ve watched about 15 videos on this topic, and yours is by far the clearest and best! Good job, sub’d!

    • @CEFPRAVEENS
      @CEFPRAVEENS 3 ปีที่แล้ว +3

      Yeah he gave perfect way to use context api with reducer

    • @raymondmichael4987
      @raymondmichael4987 2 ปีที่แล้ว +1

      This was the comment that got me curious about this video and eventually ended up watching several times. He did a real good work.

    • @the_full_stack_junkie
      @the_full_stack_junkie  2 ปีที่แล้ว +1

      🙏

  • @rachit2982
    @rachit2982 ปีที่แล้ว +1

    Great explanation. Totally worth watching 👌

  • @SatyamSharma-wi8qn
    @SatyamSharma-wi8qn 3 ปีที่แล้ว +1

    By far the only videos that explains something on this topic

  • @harisankar2010
    @harisankar2010 2 ปีที่แล้ว +1

    master class .. keep up guiding enthusiasts

  • @rightjtv7641
    @rightjtv7641 3 ปีที่แล้ว +1

    thank so much brother you save my life right now i understand well useReducer

  • @suyashtiwari8492
    @suyashtiwari8492 2 ปีที่แล้ว +1

    Brilliant video sir, subscribed 🔥🔥

  • @anthonyphilpot6178
    @anthonyphilpot6178 3 ปีที่แล้ว +1

    This is the BEST VIDEO that has helped me so far understanding this context and reducer hook! Thanks man, great teacher!

  • @Lovedeep555
    @Lovedeep555 2 ปีที่แล้ว +1

    Thanks A lot for explaining so well, I have gone through many videos even in our regional language but unfortunately I never understood, This video explained everything very clearly, Thanks again.

  • @gamerss6803
    @gamerss6803 2 ปีที่แล้ว +2

    Yo this was very helpful !!

  • @rafaelfu624
    @rafaelfu624 2 ปีที่แล้ว +1

    Implementing this hooks on the most simple idea (fewer code) is really helpful to understand. Thanks!

  • @khandoor7228
    @khandoor7228 4 ปีที่แล้ว +6

    Dude I see that you are new - 3 weeks - but your content is really solid! I sub'd and will be following you!!

  • @muxammad2777
    @muxammad2777 2 ปีที่แล้ว +1

    thank you liked, subscribed and commented . you are amazing 🤩 😍

  • @prawgspinkz8015
    @prawgspinkz8015 3 ปีที่แล้ว +1

    Why would someone dislike this video though 🤦🏾🤦🏾..
    This is well explained and very educative , i truly did learn something new from this

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว

      Wow thanks this comment means allot thank you very much!😇

  • @itishermann
    @itishermann 3 ปีที่แล้ว +4

    You're far better than the university professors here. Thanks so much. Sub'd

  • @bz6304
    @bz6304 3 ปีที่แล้ว +1

    This is the best video on globalContext with useReducer! Thank you. Subscribed

  • @hamidkhan-hs4yu
    @hamidkhan-hs4yu 3 ปีที่แล้ว +1

    I learned too much things clearly from this video, so a bundle of thanks to u sir...

  • @sadikirungo
    @sadikirungo 2 ปีที่แล้ว +1

    This truly is a work of art

  • @ashish_prajapati_tr
    @ashish_prajapati_tr 2 ปีที่แล้ว +2

    amazing tutorial

  • @serhiipyrozhenko2439
    @serhiipyrozhenko2439 4 ปีที่แล้ว +5

    Great video overall. Thanks.
    A few thoughts about Context API + Hooks.
    So, as a result, we get global storage that:
    - looks like Redux (if you want at least basic type checking and modularity);
    - works like Redux (for the most part, even including the performance for the low-frequency updates)
    And yet, it lacks its debugging power and extensibility.
    The possibility of creating multiple storages (contexts) and no need for additional dependencies can be useful if you care about it.

    • @the_full_stack_junkie
      @the_full_stack_junkie  4 ปีที่แล้ว +1

      Great overall summary of why Context is great for beginners and even little more thanks for this positive comment💪🔥

  • @faijaanmemon
    @faijaanmemon 2 ปีที่แล้ว +1

    brother , thanks thanks ♥️ I was trying so hard to learn and understand reducer and context things from 4-5 months and nothing was making sense to me, eventually got the right video ♥️ and really understood the concept and used in my other ideas and they worked, thank you again ♥️

    • @the_full_stack_junkie
      @the_full_stack_junkie  2 ปีที่แล้ว +1

      Very glad this video was able to help you understand the topic better. Thanks for comment

  • @mdshafkatsamin8241
    @mdshafkatsamin8241 3 ปีที่แล้ว +1

    you deserve more views on this video. Thank u !

  • @josevelez6865
    @josevelez6865 3 ปีที่แล้ว +1

    This was so helpful. Thank you!

  • @rizky954
    @rizky954 3 ปีที่แล้ว +1

    Thanks you so much for the tutorial mate, I learn a lot from you 👍

  • @Shakeel714
    @Shakeel714 3 ปีที่แล้ว +1

    You are a cool teacher. Keep up your valuable contribution to React learners. Thanks.

  • @devinoutfleet1998
    @devinoutfleet1998 2 ปีที่แล้ว

    Excited to be here!!

  • @AverageCho
    @AverageCho 3 ปีที่แล้ว +1

    You're great at explaining things in a simple, easy to understand way. Thanks a bunch for this amazing content!

  • @gokulpisharody3155
    @gokulpisharody3155 3 ปีที่แล้ว +2

    U know how to transfer knowledge in simple manner ,i can't belive u r just 6 months in to youtube . We need more teacher like u .

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว

      Thank you so much for this comment I really do appreciate it 🙏🤓

  • @753Manoj
    @753Manoj 2 ปีที่แล้ว +1

    Sir please upload more videos on react .... it was really full of relevant content

  • @ozzyfromspace
    @ozzyfromspace 2 ปีที่แล้ว

    I really appreciate you sharing your reducer coding pattern. When I do this, its always a mess. I'm gonna refactor a game to do this better . 😇 Thanks bro

  • @skyescrawford9774
    @skyescrawford9774 3 ปีที่แล้ว +1

    I found this video is really helpful so I leave my comment here, thank you so much

  • @mukundtiwari7207
    @mukundtiwari7207 3 ปีที่แล้ว +1

    We need more of your videos dude you are awesome ❤️❤️

  • @TheBhumbak
    @TheBhumbak 3 ปีที่แล้ว +1

    great tutorial, doing really useful work

  • @vitezslavslavik6662
    @vitezslavslavik6662 3 ปีที่แล้ว +1

    Excellent explanation of the topic, I felt lost but no more thanks to you.

  • @chenlesmom789
    @chenlesmom789 3 ปีที่แล้ว +4

    Magic indeed.

  • @nehanalini1606
    @nehanalini1606 2 ปีที่แล้ว +1

    For instant error check, we could do "disabled={!todo}" inside the Add button and the button will be disabled if we do not type anything in the input element

  • @zakidev
    @zakidev 2 ปีที่แล้ว +1

    OMG! You are born a teacher 😳

  • @shreyajoshi5148
    @shreyajoshi5148 3 ปีที่แล้ว +1

    Subscribed!!!! Sir you are doing great!

  • @mohamedyoussef8835
    @mohamedyoussef8835 3 ปีที่แล้ว +1

    Excellent Tutorial ++++++++++++++

  • @chideraachinike7619
    @chideraachinike7619 3 ปีที่แล้ว +1

    You're awesome, man!
    Much love! ❤️

  • @jaggyjut
    @jaggyjut 3 ปีที่แล้ว +1

    Pure gold. Thank you

  • @remongrabu
    @remongrabu 3 ปีที่แล้ว +1

    I enjoyed the tutorial, the way you gradually walked through the concepts really helped me refresh things. I like how you separate functionalities into partials. Buut, wouldn't it make more sense to receive toggleTodo and deleteTodo from context inside TodoItem (pass text and id as props) instead of creating a bunch of anonymous functions when you map over the todo array in TodoList? Anyway, subbed!

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว

      Hey thanks for the sub and glad you liked the video. Yess you can totally do that as well you should just then pass the id of the todo in as props from the TodoList then yess you can pull in the deleteTodo and toggleTodo into the TodoItem component. Thanks for the comment🤓!!

  • @IamTiernO
    @IamTiernO 3 ปีที่แล้ว

    Liked and subscribed. What an amazing, well put and simply explained video. The only thing I'm unsure of is how to go about implementing multiple contexts for a large application if i needed lets say a context that stores user data, one that stores posts data, one that stores company data etc. Do you nest providers or what?

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว

      So yes you would "" nest them "" so at the part where we wrap the application with the context you can just do that with the next context section. Just make sure that the order in which the context are nested can be important if working with mutliple level that might depend on wach other

  • @dangerzone-136
    @dangerzone-136 3 ปีที่แล้ว

    I really love this tutorials. Explanation is like documentation. Keep going on. Can you make a e-commerce Shoping system(product variant change, color swacther, filter, size change, quantity, add to cart) using like this conext api and react reducer?

  • @letsdoeverythinginoneweek9398
    @letsdoeverythinginoneweek9398 3 ปีที่แล้ว +1

    thanks for this amazing videoo

  • @MASTERRAGE
    @MASTERRAGE 3 ปีที่แล้ว +1

    Fuck dude after all the searching, i found something cleaaan ! thanks sir

  • @kendimce3309
    @kendimce3309 3 ปีที่แล้ว +1

    Hi, thank you so much for this gut explained video. I am wondering whether the usage of Context API in 2021 is the same. I see in some examples dispatch function much frequently

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว

      Yes from what i know it still the same. Redux on the other hand is using dispatch. This is because of the redux hooks.

  • @MrKrzysztof13
    @MrKrzysztof13 3 ปีที่แล้ว

    This was a great tutorial! I've read online that there's also the redux toolkit, is it a big difference VS the usereducer + usecontext approach? Are your MERN tutorials using the usereducer + usecontext approach? Thanks

  • @kanishkjha7621
    @kanishkjha7621 ปีที่แล้ว

    Love from India

  • @RavnitSuri
    @RavnitSuri 2 ปีที่แล้ว +1

    Thing to note! The entire tree re-renders on every context update. Even unrelated components, anywhere inside the Provider.

  • @sogggy
    @sogggy 4 ปีที่แล้ว +1

    great video, i just subbed.

  • @marcoonlinetv7769
    @marcoonlinetv7769 3 ปีที่แล้ว +1

    What you think, will this concept slowly replace redux ???

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว +1

      Probably not redux is much better for larger projects and has better structure and performance when working with large amounts of data. But that being said i do think that learning context will be more than enough for most applications. And you will also then be able to do redux so switching will be easy

  • @innocentRoot
    @innocentRoot 4 ปีที่แล้ว +1

    Good content 👍

  • @willyhorizont8672
    @willyhorizont8672 2 ปีที่แล้ว

    how about async when dispatch sir?

  • @tanishkagarwal9653
    @tanishkagarwal9653 2 ปีที่แล้ว

    when i am trying to do the same thing the color is changing to green when i click the login button 2 times and not on first time can you tell why??

  • @digitaldevboss324
    @digitaldevboss324 3 ปีที่แล้ว +1

    This seems basically the same as Redux. Is there really a big difference at this point?

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว +1

      Yes it very much is basically the same👌. The biggest different is that Redux is used for more larger project and for projects where there are many frequent updates to the state, other than that is is basically the same.

    • @digitaldevboss324
      @digitaldevboss324 3 ปีที่แล้ว +1

      @@the_full_stack_junkie I saw someone set up a template that dynamically took in the state. I was still very confused by state then, so I'll have to check that out and see how he did that again.

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว

      Would love to see this as well

    • @digitaldevboss324
      @digitaldevboss324 3 ปีที่แล้ว +1

      @@the_full_stack_junkie I went back an checked it out. It was actually a react native tutorial on Udemy so I can't share it, but it was not exactly what I thought.
      It is just refactoring the code you put in the state file, and making it a reusable function.
      Still doesn't solve the issue of multiple providers and contexts, but it does make it cleaner. I attached a quick example from my github, but in it I created multiple folders similar to your example. But it is still looked very clean and easy if you wanted to create one file with all the info instead of many...
      github.com/DigitalDevBOSS/React-Context-Reducer-Global-State

  • @aryankumar87771
    @aryankumar87771 2 ปีที่แล้ว

    how should i dispatch actions with useEffect as opposed to by clicking/submitting as shown in the video ? I get caught in an infinite loop when doing that as dispatch is a useEffect dependency and a new dispatch gets created everytime state is updated and then useEffect runs inifintely... Do you have any advice ?

    • @the_full_stack_junkie
      @the_full_stack_junkie  2 ปีที่แล้ว

      How does your dependency array look for the useEffect?

    • @aryankumar87771
      @aryankumar87771 2 ปีที่แล้ว

      @@the_full_stack_junkie
      I pass down useReducer's "dispatch" and "state" using Context.Provider with value={{state, dispatch}} and one Component has a useEffect as follows
      useEffect(( ) => {
      dispatch(addNotification)
      }, [ dispatch ])
      When dispatch runs in Component , it changes data in reducer and a new dispatch gets passed down in Context.Provider and that causes useEffect to run in an infinite loop. The problem is not there when i do just value={ dispatch }. New object reference is causing the issue. Can i use useMemo in Component ? I also need to pass down state along with dispatch. Should I shift to redux-tool-kit ?
      On TH-cam I saw examples with mostly onClick and onSubmit for dispatching actions with useReducer + useContext approach but not with useEffect. Your input will be very valuable on the correct approach.

    • @aryankumar87771
      @aryankumar87771 2 ปีที่แล้ว

      @@the_full_stack_junkie Hey man do you have a solution for this

  • @TheBhumbak
    @TheBhumbak 3 ปีที่แล้ว

    hey bro how are you using styles

  • @lukramingo1496
    @lukramingo1496 2 ปีที่แล้ว +1

    just 50 mins, I know 70% of Reactjs

  • @laponiec
    @laponiec 3 ปีที่แล้ว +1

    I ike your tutorial, but hate the fact that each tutorial does ContextApi differently, it is really hard to spot the pattern.

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว +1

      I think the goal is to understand what is does more than just seeing the pattern if you understand what it does then the pattern comes.

  • @lyledavids4513
    @lyledavids4513 4 ปีที่แล้ว +1

    Are you South African?

    • @the_full_stack_junkie
      @the_full_stack_junkie  4 ปีที่แล้ว +4

      Yes I am. Guessing my English accent
      makes that pretty obv haha

    • @ACTISAMAL
      @ACTISAMAL 3 ปีที่แล้ว +1

      @@the_full_stack_junkie Mooi gedoen! Keep up the good work.

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว

      Dankie dankie 🤓👌

    • @Mr_BetaMax
      @Mr_BetaMax 3 ปีที่แล้ว +1

      It's great to see more and more South Africans making solid content on TH-cam! 🇿🇦

    • @the_full_stack_junkie
      @the_full_stack_junkie  3 ปีที่แล้ว

      🇿🇦✌

  • @red010182
    @red010182 2 ปีที่แล้ว

    I can't belive someone use redux instead of vue 3.

  • @BobbyBundlez
    @BobbyBundlez 2 ปีที่แล้ว

    i hate how every example online is such simple examples

  • @rmt0858
    @rmt0858 2 ปีที่แล้ว

    Mujhe laga tha react asaan hai 😂

  • @ibealgoody8524
    @ibealgoody8524 3 ปีที่แล้ว

    Why is every example a fucking todo list? I need different examples to fucking learn.