Mastering React Context: Do you NEED a state manager?

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

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

  • @justine_chang39
    @justine_chang39 2 года назад +114

    honestly this channel is probably the best out there for deep dives into Typescript and React, love your content good sir

    • @tomascarignano5002
      @tomascarignano5002 2 года назад +2

      Agree

    • @SterlingCobb
      @SterlingCobb 2 года назад +2

      hey i’ve been following for a while now and this is solid. no gimmicks. pure education, learning and excellent content primarily focused in TS and JS +frameworks. would love to see Rust and wasam content integrated with js. excellent work. can’t wait to see your channel blow up beyond 100k.

    • @BillBakerB
      @BillBakerB 2 года назад +1

      Great team advice too, even you know the libraries already, "What is easier to review?" is a helpful perspective.

    • @hanmingzheng5592
      @hanmingzheng5592 2 года назад

      I was 2 videos and decide to subscribe. This channel got the real stuff compared to so many other RUclipsrs pretending to be professional developers.

    • @Gruby7C1h
      @Gruby7C1h 2 года назад

      True, this channel deserves to be much bigger - lots of knowledge and very good production quality.

  • @bythealphabet
    @bythealphabet 2 года назад +21

    Love how you Made the comparison between Context and Zustand.
    I always use Context and didn’t see why I should consider other state management tools.
    Thank you Jack

  • @padawan.developer
    @padawan.developer 3 месяца назад +1

    Hey Jack! Thanks for creating these kinds of content 🙏 I am in this stage of my career where I was positioned to coach jr developers and TBH as usual, impostor syndrome kicks in 😅
    Hence, I know I need to put the work to shake off that and learning your contents helps me to have that confidence that I know I will be able to help them grow.
    I really appreciate it and I will pay forward the learning that I am getting from your contents 🙏

    • @k303k
      @k303k 11 дней назад

      Hi are you a mid level ? I am positioned as a mid level and I also feel I need to learn more from his channel.😅

  • @tiennsloit
    @tiennsloit Год назад +4

    I don't understand why youtube didn't recommend your channel to me earlier. This video is not only about mastering React context but also the way you refactor/repurpose the components for the use of context and other state managers. Thanks so much because I learn a lot from it.

  • @lucasishuman
    @lucasishuman 2 года назад +6

    Incredibly clear and helpful demo. Please keep doing what you're doing. Your channel is by far the best I've found at showing both "the how" and "the why" of very specific and practical React + TypeScript in a very accessible way.

  • @viyicciyiv
    @viyicciyiv Год назад +2

    Never really understood what context and Redux do, and you explain it so well with clear examples. Thank you!

  • @marcelwopperer9776
    @marcelwopperer9776 2 года назад +2

    adding this facade layer is genious

  • @AmodeusR
    @AmodeusR 2 года назад +2

    It's really neat how you go building the example structure till you get on the topic of the video instead of already showing everything done and and explaining. I really liked that :D

  • @AbdelhameedG
    @AbdelhameedG 2 года назад +1

    Thank you, Jack, You have the best Front-end channel on YT. Keep it up.

  • @siriusplayz5871
    @siriusplayz5871 Год назад +3

    WOW! I mean really WOW... You are such a GREAT teacher. Teaching with examples and passing down all that precious knowledge with such an ease. Brilliant. I'm a fan. First video I watch on your channel and I'm subbed forever.
    I just started learning React 2 months ago and this helps a looootttttt.
    Thank you sooooo much man.
    I'll keep coming back for more knowledge as I need to get a job very soon, hopefully.

  • @Tarabass
    @Tarabass Год назад +1

    You did it again. I'm a developer for decades now and to be honest, I'm getting very annoyed by all those wanna be's out there.
    I'm trying to level up my knowledge about react (although I hate it) and every ninja is telling you to use context for global state. My guts feeling told me that is not a good idea. I don't want to rerender everything to update some fields. I even think that prop drilling is better.
    I follow your channel for a long time now and I'm glad you gave me the answers I was looking for. In a decent and professional way with proper knowledge and terminology. Thank you!

  • @bielgaucho_real
    @bielgaucho_real 2 года назад +5

    I always asked why people use redux for everything, while they could achieve the same with context or simpler state management libs. This video is proof of it. Unfortunately using context takes a lot of care to avoid re-renders, but zustand demonstrate it can look simple and do the job.

    • @jherr
      @jherr  2 года назад +5

      Just remember to make sure you use selectors with your zustand hook. :)

  • @mistersir3185
    @mistersir3185 Год назад +2

    Just when wet thought we don't deserve this a high quality educative content, you showed up and said we deserve it.

  • @fadehelix
    @fadehelix 2 года назад +2

    Thank you for this episode. In my personal ranking this is the best Context explanation I've ever seen

  • @tonyg_nerd
    @tonyg_nerd Год назад +1

    There is a ton to digest here. Will be watching this many times. Thanks Jack!

  • @orthostice
    @orthostice Год назад +1

    I think this video changed my life. Well, my frontend architecture but same thing right now.

  • @stevebob240
    @stevebob240 2 года назад +1

    Exactly what I needed, still getting familiar with React and Next JS. Thanks!

  • @universecode1101
    @universecode1101 2 года назад +23

    Mastering with the MASTER 🔥Every video is great, sometimes too much 😄, I mean I have seen the video even twice because you reach a high level, but with you Jack, I can improve my skills. Thanks ✌🏻

  • @braingamedotcom
    @braingamedotcom 2 года назад +1

    This is a high quality video with great content, something really refreshing on RUclips! Thank you very much 🙏

  • @EveryDayLifeWithDiabetes
    @EveryDayLifeWithDiabetes 2 года назад +3

    These series of mastering are amazing, Thank you very much man, I have learned lots of things from you and I owe you a lot :)

  • @tabliqatchi6696
    @tabliqatchi6696 Год назад +1

    Amazing video Jack, I really enjoy watching the way you write and talk about code. Your channel is absolutely phenomenal.

  • @Kahitar1
    @Kahitar1 2 года назад +1

    Insanely good video. Perfect level of detail and nice comparison between the different options. I learned a lot from this.

  • @JamesBond-mc7kl
    @JamesBond-mc7kl 2 года назад +1

    I just start career in React js and found the great video that is helpful for me

  • @ogreeni
    @ogreeni 2 года назад +1

    Fantastic comprehensive overview! Love your videos Jack, been following you for a long time now.

  • @olyvar
    @olyvar Год назад

    So much great things covered in this video. Also a shout-out for passing the set state as a prop and using the callback to get the state value. I never thought of that before!

  • @tonystark4416
    @tonystark4416 2 года назад +1

    Thanks! This was really helpful, even though I probably need to rewatch and read the docs a couple of times still

  • @prathameshmali3888
    @prathameshmali3888 2 года назад +1

    The comparison is really good, especially with the profiler. Didn't know that context will make those many changes to the tree. Thank you Jack for the awesome video!

  • @lancerdonnie
    @lancerdonnie 2 года назад +1

    You really know your stuff. This is where I strive to be in the future

  • @jacobgoldenstreet6246
    @jacobgoldenstreet6246 2 года назад +1

    Wow. Fantastic tutorial. Your teaching is very clear. Super helpful. Thanks!

  • @sumitwadhwa8823
    @sumitwadhwa8823 2 года назад +1

    Even some of the paid content out there is not as impressive as your content sir. Thank you so much.

  • @pendyaaa
    @pendyaaa 2 года назад +1

    This is a really really awesome video. Way Way better than all those tutorial style videos which only is a regurgitation of documentation. This actually deepens my understanding and give me ability to judge new state management tools for myself

  • @danbacila5257
    @danbacila5257 2 года назад +1

    Amazing content, I have been following the channel for a while now. As a Junior dev I can say that this channel motivates me to dive deeper into concepts and try them out on my own in a series of little projects.
    Keep up the good work and high quality content, Jack!

  • @shike769
    @shike769 2 года назад +1

    Watched 2 of your videos.
    great content, very informative and very well edited.
    Thanks a lot for the effort

  • @rdubb77
    @rdubb77 Год назад

    In the dark and dangerous world of React over complexity you are beacon of understanding and hope

  • @psychobuddha5379
    @psychobuddha5379 2 года назад

    I am pretty impressed with how easy and clearly he manages to explain these concepts... Zustand sounds pretty interesting, I am definitely gonna try it.

  • @Kelz_369
    @Kelz_369 2 года назад +1

    Wowww 👏 this is the most thorough explanation on state management I've come across on yt. Definitely sub to this channel. Thanks!

  • @yassinebi337
    @yassinebi337 2 года назад +1

    Great video, I’ve learnt a lot from your youtube channel, keep up the great work.
    Greeting from Morocco.

  • @krazymeanie
    @krazymeanie 2 года назад +1

    Bruh this channel is a blessing

  • @Peter911
    @Peter911 2 года назад +1

    Best in depth explanation and for free woow you are amazing .. Thank you

  • @noccer
    @noccer 2 года назад +1

    Terrific video, and very topical for my team at the moment as it would happen. Thank you as always ☘

  • @maniacos2801
    @maniacos2801 2 года назад +2

    Bzw it's "Zustand" (German "state") with hard Z like the S in "state", "sort", "set"...

  • @marksalsbery9826
    @marksalsbery9826 2 года назад

    Another great video….it’s amazing how many little things I learn mixed in with the major topic stuff. Thank you!
    Also, you are a great salesman for Copilot…the more I watch you write code the more I want it!

  • @teerapatprommarak2070
    @teerapatprommarak2070 2 года назад +1

    This is really really GREAT content Jack, thank you!

  • @HeinekenLasse
    @HeinekenLasse 2 года назад +1

    Amazing video Jack, thanks for the effort

  • @hamedmatari2577
    @hamedmatari2577 2 года назад +1

    Finally I got the answer of this famous question, what is difference between redux and context. Your channel was always the best. I guess every body can find their question's answer in your channel. good to have you jack🤩

  • @tarek_maza
    @tarek_maza 2 года назад +1

    An awesome resource for understanding state management in React!

  • @haquocviet9253
    @haquocviet9253 2 года назад +2

    Great content and easy to understand. Thank you so much

  • @igotbit9454
    @igotbit9454 2 года назад +1

    Love this channel!!!!!!!!!!!
    My go-to for React/JS stuff cause it covers more than just the basics which is what is needed in the real world env.
    Thx for the vids Jack!

    • @igotbit9454
      @igotbit9454 2 года назад

      PS. these days i'm using Apollo Cache/Reactive variables to pass state around instead of React Context but React context is great too.

  • @mateuszkulesza8528
    @mateuszkulesza8528 Год назад +1

    Great video, Zustand looks very promising

  • @spirostsakoulis797
    @spirostsakoulis797 Год назад +1

    Thank you so much for this great tutorial!

  • @esraashahien3467
    @esraashahien3467 Год назад

    I am getting the error "RangeError: Maximum call stack size exceeded" and it is pointing at the "useStore" custom hook. This happens when I start using Context and context-selector.
    25:38 Replacing Zustand With Context
    29:37 When Context Updates Components
    30:10 Context Using use-context-selector

  • @javierjrueda1722
    @javierjrueda1722 2 года назад +1

    Thank you so much for this video. Really useful.

  • @okiirawan9578
    @okiirawan9578 2 года назад +2

    easy peasy lemon squeezy, thats the master said.
    Another very informative contents, so excited to watch your videos 🔥🔥🔥

  • @farzadmf
    @farzadmf 2 года назад +1

    VERY GOOD explanation, thank you!

  • @stefan9599
    @stefan9599 2 года назад +2

    Great content as always. Thank you Jack!

  • @sumanth3036
    @sumanth3036 2 года назад +1

    You just dont stop at a superficial layer. Thanks a ton!!!!

  • @petarkolev6928
    @petarkolev6928 2 года назад +1

    Thank you for the wonderful video, Jack!
    I work in this industry for 5 years and yet I found all of your videos amazing and incredibly informative! All your videos are precious gems :)
    Only one thing I found a little bit hard to follow is the pace you go through your code in the editor. Personally, for me is a little bit hard to follow with that speed. May be for others is okay :)
    Thank you once again for the cool stuff you're showing to our fellow programmers :)

  • @BensTechLab
    @BensTechLab 2 года назад +2

    Let me just say what no one else notices… your video lighting and green screen setup is superb! 🙌 As a video guy I know this takes a bit of a setup/tweaking to get such a clean key without green spill around you.

    • @jherr
      @jherr  2 года назад +1

      Thanks. I've been working on it and improving it over time. I think the most recent videos have been pretty solid.

  • @ChristianNikolov-h3x
    @ChristianNikolov-h3x 11 месяцев назад

    one reason I favour the state managers over the context api is that you can access your state even outside your react components and sometimes thats a requirement. not sure if you can do something like.
    import contextApi from 'mycontextapi';
    contextApi.value ... etc.

    • @jherr
      @jherr  11 месяцев назад

      You are correct. Making the data in the context available externally would be something you would have to implement. But there is `useSyncExternalStore` that you might want to look into. It's designed specifically to connect React components to external state managers. So if something off the shelf doesn't fit your needs there is that.

  • @olabiranjoshua2860
    @olabiranjoshua2860 2 года назад +1

    This is such a rich content. Thanks for this Jack 👏🏽👏🏽👏🏽

  • @stevemiller123
    @stevemiller123 2 года назад +2

    It says Error: CounterContext is undefined? This happens after I move components to to there own files.

    • @jherr
      @jherr  2 года назад

      You should jump on the Discord server and ask your question there.

    • @stevemiller123
      @stevemiller123 2 года назад

      @@jherr I posted the question there, thanks Jack!

  • @parassharma7041
    @parassharma7041 2 года назад +1

    I'm new to your channel, loving your videos great content and thank you for teaching with great easy way 😀

  • @sarthak1317
    @sarthak1317 10 месяцев назад

    thanks for the ecommerce example, adding it to the project section in my resume. A full fledged ecommerce app with login logout and add to cart functionality 😎

  • @TopGearScooter
    @TopGearScooter 2 года назад

    At the 3:00 mark, how would you write the same code in typescript?

    • @jherr
      @jherr  2 года назад +1

      AddOneButton: React.FunctionComponent number) => void} = ({setCounter}) ...

  • @Curaaheevil
    @Curaaheevil 2 года назад +1

    How would type and set a default value for the context with useState using typescript?

    • @jherr
      @jherr  2 года назад

      I usually create an `initialValue` object and then set the type of the context to be `typeof initialValue`.

  • @kaykhan3517
    @kaykhan3517 2 года назад +1

    Should your store.ts hold functions to make api requests? e.g a refreshData function might need to fetch data from an api and save it to state? can this be done in a single function e.g a useRefreshData hook?
    Struggling to understand what are the limits of this store
    AND looking for examples/information around using state manager and facade layer. if you have any

    • @jherr
      @jherr  2 года назад

      A "store" is just a separation of concerns between UI and the business logic. It's limits are whatever you want in terms of architecture.

  • @niwasikajhos
    @niwasikajhos 2 года назад +1

    How about spatial data? What's the best options to use?

    • @jherr
      @jherr  2 года назад

      Spatial data isn't my specialty. Doesn't that usually involve specialized data structures optimized for dimensional search?

    • @niwasikajhos
      @niwasikajhos 2 года назад

      @@jherr yes sir, most usually using d3 on advance destructuring data, now on my project using context on development, until now I dont have any problem, I don't know when in the future, I have setup using sql to query data.

  • @garywaddell6309
    @garywaddell6309 2 года назад

    Hey Jack I have been watching video after video of yours. I am still in my deep dive of React and MFE's so would be curious if you had a video on managing State / Context via Module Federation, specifically around JWTs and how to control flow in MFEs for valid / invalid sessions. I'll keep looking through your library but this video along with every video you make is so informative. Thanks for publishing such amazing content!!

  • @eleah2665
    @eleah2665 2 года назад +1

    The University of React State is back in session! Thanks Jack. I will want to get Mr. Kato's book.

  • @wisdomcube7789
    @wisdomcube7789 2 года назад +1

    Happy Valentines Day... also great content as always, thank you

  • @vishalgaurav4411
    @vishalgaurav4411 2 года назад +1

    what was the tool you used which shows a green border around when dom update takes place?

    • @jherr
      @jherr  2 года назад

      React dev-tools

  • @1Malak16
    @1Malak16 2 года назад +2

    Thank You! Briliant as always.

  • @mike-2342
    @mike-2342 2 года назад

    Your office environment is amazing.

  • @jessewillard9053
    @jessewillard9053 2 года назад +1

    What's your zsh styling setup?

    • @jherr
      @jherr  2 года назад

      oh-my-posh with the powerlevel10k_rainbow theme

  • @AwakeningofAI
    @AwakeningofAI 2 года назад +1

    Thank you very much, sir. Great content.

  • @apresthus87
    @apresthus87 2 года назад

    I used to use Redux (Redux toolkit to be precise) and it's still used for one of my active projects but in my latest project where I created my own CMS from scratch I used purely React Context for local state management and it was a very good experience. It's not like I dislike Redux toolkit (which is a pretty big upgrade on regular Redux imo when it comes to dev experience), but it was really nice to not have to put in a ton of dev time for the project on just state management.

  • @chrisprenn
    @chrisprenn 2 года назад +1

    Awesome video thank you so much!

  • @rathodmahendra7264
    @rathodmahendra7264 2 года назад +1

    What intellisense extension you are using ? It seems very powerfull.

    • @jherr
      @jherr  2 года назад

      GitHub Copilot

  • @eddiedotdev
    @eddiedotdev 2 года назад +1

    What's funny to me is that I see this video after seeing the newer "Do you NEED context?" videos :D

  • @reymarkandog1441
    @reymarkandog1441 Год назад +1

    Can we use Zustand with React Query?

    • @jherr
      @jherr  Год назад +1

      Yes. Though realize you'll probably have to sources of state. RQ for the response data from services. And Zustand for all the transient user state as they use the UI.

    • @reymarkandog1441
      @reymarkandog1441 Год назад

      @@jherr Great.

  • @Luxcium
    @Luxcium Год назад +2

    I have kind of learned HTML a thousand times over the years and skipped it because JS and CSS where so cool but HTML is so basic it is thought only to beginners I think you are the perfect person to teach us (i.e. We already know * "Hypertext" refers to links that connect web pages to one another, either within a single website or between websites*) you must do an HTML tutorial for people who knows the basics and give us the advanced tools to master HTML in the context of React and with the minimal CSS or styling possible for it to be interesting but focusing only on HTML (in the context of React probably)… 😅😅😅😅 I would love to get my HTML certification 😉😌😜

  • @michaelquintero2315
    @michaelquintero2315 Год назад +1

    excuse me does your editor have cursive letters in it? Absolute madman

  • @chauklaus2693
    @chauklaus2693 2 года назад +2

    Does use-context-selector support multiple contexts? I really like Zustand but then I realised it did not really fit in one of the projects I was working on as it didn't support multiple contexts, which was required for that project, unlike the context provider (please correct me if I am wrong) 🤕🤕

    • @jherr
      @jherr  2 года назад +1

      Use context selector is a plug-n-play exchange for createContext, so, yes.

  • @sergeitinc
    @sergeitinc 2 года назад +1

    Thank you so mush Jack!

  • @korkmazsalim
    @korkmazsalim 2 года назад +2

    Thanks Jack great content . Btw is there a solution in zustand for creating state slices and naming them so when project gets bigger we can inspect them by redux toolkit with the slice names ? ( i can combine at store but they are spreaded in toolkit).Thank you..

    • @jherr
      @jherr  2 года назад +2

      You make multiple stores. I think that's the basic idea. One store per, what you would categorize as a "slice".

  • @heangly7449
    @heangly7449 Год назад +1

    Jack, you are so amazing. I would be so happy if you can create full stack web development course. I am sure many people (including me) are willing to pay for your course.

  • @franksiret1800
    @franksiret1800 2 года назад +1

    great video, only one thing, I like the way vscode do the autocomplete code... how it is call the extension ?

    • @jherr
      @jherr  2 года назад

      GitHub Copilot

    • @marcwinner567
      @marcwinner567 2 года назад

      @@jherr I would appreciate if you could share your thoughts (either here in the comments or in a video) regarding on how you use Github Pilot and what pros and cons it has for your workflow. Thanks!

    • @jherr
      @jherr  2 года назад

      @@marcwinner567 ruclips.net/video/7I-CY1a-Jpk/видео.html

  • @slabdev
    @slabdev 2 года назад +1

    Thank you for great video. What is the name of the extension that shows inline debug info in your vscode?

    • @jherr
      @jherr  2 года назад +1

      GitHub Copilot.

  • @ivuga1800
    @ivuga1800 Год назад

    Thank you for the video! Where I can get same syntax highlighting?

  • @prabhatsachdeva7747
    @prabhatsachdeva7747 2 года назад +1

    LOVING THIS MASTR SERIES 🖤

  • @sivaganesh4489
    @sivaganesh4489 2 года назад +1

    Thanks Jack for great explanation. can you please share your vscode extensions

    • @jherr
      @jherr  2 года назад +1

      Here is my full setup: gist.github.com/jherr/cb8770e2ae92a7646d22c126be896a72

  • @buthow900
    @buthow900 2 года назад +1

    what about jotai + valtio. I think we are moving toward an atom based state managers, and the proxy pattern reduces the boilerplate of writing selectors

    • @jherr
      @jherr  2 года назад +1

      Those are great. I just picked Zustand because it was easy and familiar. But those are awesome as well. I love atomic state management.

  • @pupfriend
    @pupfriend 2 года назад

    fascade layer is genius, but how do you access zustand methods like .subscribe if we abstract it away like that?

    • @jherr
      @jherr  2 года назад +1

      You'd have to expose the subscribe somehow. Nice thing is that you can control that API surface as well.

  • @ninabohm1535
    @ninabohm1535 9 месяцев назад

    Thanks Jack, very helpful!

  • @grugbrain
    @grugbrain 9 месяцев назад

    Since setting state in the client component function body, also gets run on the server side, the app consumes a lot of server memory when I have a lot of stores. 😥

  • @jp0678
    @jp0678 2 года назад +2

    While I'm kind of already familiar with this concept, I still learn some new stuff here and there when you explained it. Thanks!
    By the way, what extension do you use for that autocomplete?

    • @jherr
      @jherr  2 года назад

      GitHub Copilot.

    • @jp0678
      @jp0678 2 года назад

      @@jherr Oh, I see. Thank you!

  • @hristoenev6733
    @hristoenev6733 2 года назад +1

    Really good content! Thank you.

  • @codedusting
    @codedusting Год назад

    Even though we are not doing prop drilling, the all the components still re-renders. Isn't this the performance issue? Shouldn't only Counter one should re-render?

    • @jherr
      @jherr  Год назад

      Can you give me a time reference?

    • @codedusting
      @codedusting Год назад

      ​@@jherr 9:06 So, I thought that when you use this context method, only AddCounter and Counter components should render and not Container or Container's parent.

    • @jherr
      @jherr  Год назад +1

      @@codedusting I don't have a ton of time to watch all the context around this but whatever component has the Provider, which has a useState, is going to be updated because when the state is set the provider and whatever included it is going to be re-rendered.

    • @codedusting
      @codedusting Год назад

      @@jherr Thanks. Got it.

  • @ToddDunning
    @ToddDunning 2 года назад +1

    Jack I click "Like" on your vids before even watching them

  • @jakemetz1742
    @jakemetz1742 Год назад +1

    Always amazing content that’s prepared so well.
    Curious, what tools you use to make your videos?
    Would love to dem to my team in the same format

    • @jherr
      @jherr  Год назад +1

      I use ScreenFlow to capture the screen. If I drew on the screen then I was using ScreenBrush and a commodity Gaomon drawing tablet. And then for post production I use the Adobe Suite. Honestly through, in most cases you could get by the just using ScreeFlow and a decent microphone.