React State Management - Intermediate JavaScript Course

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 มิ.ย. 2024
  • React State Management is half of your React app so it is important for React developers to understand. In this full intermediate React tutorial, you will learn how to implement state management using industry best practices.
    ✏️ Jack Herrington created this course. He is a principal full stack engineer. Check out his channel: / @jherr
    💻 Code!: github.com/jherr/fcc-state
    ⌨️ (0:00:00) Introduction
    ⌨️ (0:03:27) useState
    ⌨️ (0:18:37) useReducer
    ⌨️ (0:32:29) useMemo & useCallback
    ⌨️ (0:49:43) useEffect
    ⌨️ (1:05:59) useRef
    ⌨️ (1:13:53) Context and Custom Hooks
    ⌨️ (1:41:48) React Query & React Location
    ⌨️ (1:57:26) Zustand
    ⌨️ (2:06:11) Valtio
    ⌨️ (2:12:44) Jotai
    ⌨️ (2:20:51) Redux
    ⌨️ (2:37:56) The new use hook
    ⌨️ (2:44:26) Recommendations
    ⌨️ (2:46:07) Outroduction
    🎉 Thanks to our Champion and Sponsor supporters:
    👾 Nattira Maneerat
    👾 Heather Wcislo
    👾 Serhiy Kalinets
    👾 Erdeniz Unvan
    👾 Justin Hual
    👾 Agustín Kussrow
    👾 Otis Morgan
    --
    Learn to code for free and get a developer job: www.freecodecamp.org
    Read hundreds of articles on programming: freecodecamp.org/news

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

  • @Hizbullla
    @Hizbullla ปีที่แล้ว +137

    Despite React's popularity it's so hard to find proper intermediate to advanced explanations about the nuances of the library. Seems like most React developers just copy paste and adjust code until they get the desired outcome. It's for this reason that I love Jack for his contribution to the tutorial landscape.

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

      I feel the same way.

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

      You are right, Jack, Theo & some other dudes help with more advanced / senior things, rather than typical todo lists and stuff

    • @technical3199
      @technical3199 11 หลายเดือนก่อน

      yeah same here lol

    • @mosesmolepo1702
      @mosesmolepo1702 6 หลายเดือนก่อน

      I'm guilty

    • @Farouk-Dev
      @Farouk-Dev 10 ชั่วโมงที่ผ่านมา

      Samee ❤

  • @renielrabie9035
    @renielrabie9035 ปีที่แล้ว +35

    I don’t think I’ve ever commented on a TH-cam video, but Jack Herrington is one of the best teachers I’ve seen on the channel. Thank you, Jack. Thank you for a fun time learning state in React!

  • @melkenhoning158
    @melkenhoning158 ปีที่แล้ว +17

    This instructor is really skilled at explaining in just enough detail, good choice!

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

    This was one of the most comprehensive tutorials I've watched,. I really like how you gave examples of why the state doesn't change when discussing useState.

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

    This is a really great mini course. Loved it! I went and followed Jack's channel as well! Thanks for putting this together.

  • @andreainvernizzi8510
    @andreainvernizzi8510 ปีที่แล้ว +29

    I learnt more about useState in 20 mins explained here than in a whole term of web development diploma from conventional education.
    I am so thankful to value-oriented YT channels like this one, are free sources of knowledge and value to everyone at the cost of an internet connection.
    Thank you for delivering this content about React

    • @lukas.webdev
      @lukas.webdev ปีที่แล้ว

      I just posted a video about the same topic (in 2023) - maybe this could be interesting for you as well. 😉

    • @marvinfok65
      @marvinfok65 5 หลายเดือนก่อน

      Agreed! I no longer want to learn from conventional education! They set a time frame and just throw everything to you and expect you to know and they considered their job done!

  • @nikolakikanovic9740
    @nikolakikanovic9740 ปีที่แล้ว +80

    Jack is actually one of few rare guys that covers and teaches you intermediate topics about react/next and typescript on his channel.
    One thing that I also like for him is that he with all that knowledge, you hear from the voice that he is still on to ground without any ego-trips, he is there to only teach you and transfer a knowledge.
    Good job Sensei!

  • @studyingasyouwere
    @studyingasyouwere ปีที่แล้ว +13

    I learnt HTML and CSS from your channel from scratch and now I am posting my own web dev content! Thank you for your work :)

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

    wow, this is actually super important and it was so hard to actually find something that covers these concepts so well. thank you!

  • @tjdgmlchl6305
    @tjdgmlchl6305 11 หลายเดือนก่อน +1

    Best tutorial. This is so helpful. Words cannot explain how grateful I am to have access to invaluable educational material like this.

  • @germanguerci1744
    @germanguerci1744 5 หลายเดือนก่อน

    This is the most important video about React I have ever seen in over 3 years of using React. Thank you!

  • @Eddie4k
    @Eddie4k ปีที่แล้ว +9

    This is seriously such a great instructor!

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

    Awesome tutorial.
    The only thing missing of the useState video is the classic example with 3 consecutive setCount functions that add 1 but the user get 1 again as a result.
    Then you teach about previous state!

  • @usmanmalik-xk5vi
    @usmanmalik-xk5vi หลายเดือนก่อน

    Awesome resource man, Thank you for not just explaining how state management works but how the underlying data structure is handled by JS for example by reference and by value.

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

    This man is the reason I went from junior to medior. You seriously must watch his videos if you're serious about a career with React.

  • @jigneshpatel8975
    @jigneshpatel8975 7 หลายเดือนก่อน

    It's Incredible! Got the actual understanding of state management from this. Kudos to Jack!

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

    easily the best react video and the best teacher. thank you for doing this !

  • @r-i-ch
    @r-i-ch ปีที่แล้ว +3

    Jack is maybe the best intermediate content creator. Glad to see him here!

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

    Jack, You are AWESOME!!!! I think this tutorial was by far better than other react and state management's videos I've seen so far. Thanks for sharing your incredible knowledge.

    • @lukas.webdev
      @lukas.webdev ปีที่แล้ว

      I just posted a video about the same topic (in 2023) - maybe this could be interesting for you as well. 😉

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

    your always great ,right time providing right course for the subscriber .thanks for the educator

  • @user-oz7eu7ps9r
    @user-oz7eu7ps9r 10 หลายเดือนก่อน

    I have been learning react since months but this video just hit different! Jack is so amazing! Only after watching this video did I truly understood stage management!

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

    Thank you sir. Your useEffect video was very informative. i learned the why along with the how

  • @thwackspongbelm
    @thwackspongbelm 5 หลายเดือนก่อน

    Highly instructive, thank you. 18 minutes in, I can't wait to watch the rest

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

    Thank you very much for this course, I think you explain the best among the lecturers.

  • @ChristopherBrown-bj4zl
    @ChristopherBrown-bj4zl 4 วันที่ผ่านมา

    Alright... 7 minutes in and I can already tell this is a good video. So many "tutorials" gloss over the nuances of lines of code and this tutorial doesn't. This tutorial also goes a step further by showing code that you would think would work, but actually doesn't and explains why. For me, I need this. I need to know why something is happening, because under-the-hood/behind-the-scenes magic never works for me in the long run.

  • @umair.ramzan
    @umair.ramzan ปีที่แล้ว +1

    Thanks for this, it's really worth the time I have put into it.

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

    Jack is a monument and I'm so glad to see him here on FCC ❤

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

    Great refresher , Yet learnt some new things.

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

    this is really well explained. thank you

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

    Fantastic tutorial!! Thank you.

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

    Jack is the best talking about React and Next 🔥🔥

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

    I'm interested to know how to create this with TypeScript.
    Excellent tutorial.
    I will spend the next couple of days to build alongside.

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

    Next make a Advanced React course. it will help me greatly in my job. Thank you for all the awesome content.

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

    Jack is great. Do whatever he tells you to do. You will thank him later.

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

    Best of the Best, ty Mr.Herrington a lot. You are really awesome

  • @totallypointlessvideos3832
    @totallypointlessvideos3832 9 หลายเดือนก่อน

    This is really and awesome video. Many thanks for this!

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

    I did a hit on like button, when i was at 17:11 ( setLIst( [...list, name ] ) ). Thank you so much master, for this vauable source

  • @HammadUrRehman-gy9vs
    @HammadUrRehman-gy9vs ปีที่แล้ว +4

    Great course, Just one correction In useRef section if we do "useState([{id: idRef.current++ , name:"john"} , {id: idRef.current++, name: "Jane"} ])" then upon every re-render idRef value gets updated two times, that maybe because of the development mode which follows "mount unmount and then again mount lifecycle". Note: "On second entry you will get the id 8 instead of 4"

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

      Thanks bro I was thinking about this

    • @kharadinbrahman
      @kharadinbrahman 8 หลายเดือนก่อน

      just found that out yesterday and commented. one better just set the numbers in the useState initial values.

  • @AurelianoShowsTheWorld
    @AurelianoShowsTheWorld 8 หลายเดือนก่อน

    Thank you, that's a very nice video!

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

    A master piece!! The vscode configurations is from another planet 🤯 Can you share please

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

    Loved the squirrel raiding the bird feeder in the start of the video 😂

  • @juanmamani2110
    @juanmamani2110 หลายเดือนก่อน

    best 2:46 of the day! thanks for sharing!

  • @krobi26
    @krobi26 10 หลายเดือนก่อน

    I've been using React for about a year and a half, but I think I got 50% better at React by just watching this course.

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

    Hello Jack. Thank you for your time and effort to help improve our skills. Question: I have modified your code slightly where I am importing an array of names instead of hard coding it in the components. I am running into a slight problem where I cannot add a coma and space between the names from the array. how can I add this minor detail? Thank you for your time!

  • @developerpranav
    @developerpranav 7 หลายเดือนก่อน

    This might be the last state management video one needs to watch for a long time, until they hit any limitations (which I dont think they will for a long time!)

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

    45 minutes watched BTW what a great Tutorial !!! awesome

  • @nodeSkin
    @nodeSkin 9 หลายเดือนก่อน

    This man is just amazing !!!

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

    I am on 1:13:40 and I was following along and everything was going fine but then the tutor switched to Typescript and starts teaching in it If they wanted to teach in Typescript they should sticked to it since the beginning or they should have notified that things will be taught in TS later in this course as a person who has no knowledge in TS now i have to learn it then i have come back to this course and resume this course it will just waste the time, for those who don't know TS

  • @user-gf9ri4wj5h
    @user-gf9ri4wj5h ปีที่แล้ว +1

    Masterpiece!

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

    Hey Jack !
    Awesome video man. Clear all the fundamentals in one shot. Can you let me know what VS Code extension you are using, that seems to be doing wonders as well.

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

      Quokka.js is the one you are amazed by I guess. Or possibly, console-ninja

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

      did you get the answer dude? let me know if you did.

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

      for auto complete? I think its Tabnine extensions

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

      @@Ujedkemal for auto complete? I think its Tabnine extensions

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

    I already know this will be epic..

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

    Jack's a legend. Thanks for the pokeymon man.

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

    this is absolute gold

  • @wahajahmed2823
    @wahajahmed2823 2 หลายเดือนก่อน

    One of the greate video. 🤩🤩

  • @vivekkumar-pc1xy
    @vivekkumar-pc1xy ปีที่แล้ว

    you are the master of javascript

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

    You know it's going to be a good React tutorial when the instructor doesn't use CRA

  • @birandkoray
    @birandkoray ปีที่แล้ว +215

    Donald Trump is back to "Make React State Management Great Again"

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

      Bhut Hard 😂👍🏻

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

      Sur 😹

    • @JoonhwanLee
      @JoonhwanLee ปีที่แล้ว +13

      great united STATES again!

    • @nicka.9057
      @nicka.9057 ปีที่แล้ว +1

      🤮

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

      It's gonna be huuuuggggeee!!!

  • @jpmitchell925
    @jpmitchell925 8 หลายเดือนก่อน

    This is actually gold

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

    Excellent teacher!!!!

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

    would love to see a tutorial about swr in terms of state management, and maybe compare it to react query

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

    Hey @jherr, this video is really incredible! Great job!
    Any idea why Beedrill is the first Pokemon on the useContext results at 1:40:22, but not on the Jotai results at 2:18:51? Is it because you sliced a different amount?
    I really like the atomic model. I'm gonna have to try Jotai out.

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

    Jack, please what's your font and your VSCode theme?
    thank you for the amazing tutorial

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

    im forever using use reducer for my forms

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

    Great vid!

  • @kharadinbrahman
    @kharadinbrahman 8 หลายเดือนก่อน +2

    1:13:36 Jack, it gives an error as it is, useRef: it runs ok with values like 1, 2, 3... but then it comes obvious that the ++ increments in the useState are fired every time and the count increases by 5, if in strict mode, or by 3, if you comment out 'strict' mode., so what one can do is to assign numbers: id 1 and id 2 for John and Jane, and start the count with 3. (or 2 and pre-increment the id)

    • @herreranicoo25
      @herreranicoo25 7 หลายเดือนก่อน

      Thanks for this!

    • @amithanilgeorge4956
      @amithanilgeorge4956 5 หลายเดือนก่อน

      Thanks for this,but i don't understand reason behind this ,is it because setting useState which lead to render this it results in increamenting refId more times?

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

    Superb course

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

    Awesome.. Tutorial Jack... purely delighted... Thank you so much!!! Do you mind telling me what is the theme that you used in visual studio code... really liked it and how all keywords are italic... please help me on this

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

    Will keep this video for future reference. Thank you freecodecamp and jack. I just wish recoil was part of this video.

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

      Jotai is, and that is very close and IMHO better.

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

      @@jherrsir if you vouch for it, I will definitely definitely look into it.

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

    Best instructor

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

    Thank you very much Sir.

  • @bengorman1722
    @bengorman1722 5 หลายเดือนก่อน

    Thanks for the great video Jack! Regarding useReducer, the current React 18 docs examples declare the reducer function *outside* the component body. Besides reusability, is there any reason to do it this way as opposed to declaring the reducer *inside* the component?

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

    awesome video, does anyone knows what extension he uses for shortcuts in react (or more in general what do you guys would suggest?)

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

    High quality intermediate to advanced React contect

  • @john-dolaspassiveincomestr9144
    @john-dolaspassiveincomestr9144 8 หลายเดือนก่อน

    My eye just pop open. Jack thanks

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

    Hello, I love your videos about kivy)) I have a question: I will develop a mobile app and upload it to the Google Play. What do you think, can I use kivy or it is better to use java?
    Thank you)

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

    Cca 17:30
    Why not using the "prevState" for updating the array?

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

    Could you record a video about eventrix? It’s a new open source alternative for redux that our company created and we want to share our work with the world :)

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

    what extensions are you using? how can you run typescript file apart from others (when you open typescript workbook 19:30) - how does the VSCode shows the result in front of the code?

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

      That's Quokka.

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

    Good explanations, can anyone provide some advice about project structure/folders when building medium sized app using hooks for local state and context or maybe zustand for global state ? some boilerplate repo would be appreciated too

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

    Hi, Thank you for your awesome video....what is your extension to complete code in react

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

    Jack is awesome, very knowledgeable and insightful! Nevertheless, I got a few questions:
    1. Example with Pokemon context used setSearch function inside a hook. Isn't it a good way to move such functions outside of a hook, changing its signature to expect dispatch as a parameter? As a benefit of this approach you'd make setSearch treeshakable, and wouldn't ship dead code in case a consumer doesn't even need it.
    2. Regarding the zustand example... Your setAllPokemon function derives new state based on search criteria and a list of pokemons. The question is why do you prefer keep derived state in a store, and call filtering-sorting function two times in a store, instead of inversion the responsibility to filter sort pokemons IF it is needed to the consumer of the store. As far as I understand you could provide a selector for this purpose, aren't you? (i'm not sure since I haven't used zustand and frankly rarely use react). Btw this separation of concerns is what I liked when you showed vatio.
    3. This one is more of a wish than of a question) I would really love to see you explaining the example with simple rxjs state management approach. I guess it would be kinda in a family of atomic state management, but light light weight, isn't it?
    And I also wondering about having a good analysis of pros and cons of those state managers compared to each other)

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

    "How coooool is thaaat?" :D

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

    you always surprise me with the super white bg.

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

    Forgive me for not knowing exactly how to ask this but what is the tool used for the suggested autocomplete when coding?

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

    Thank you sir ❤🙏

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

    What is the name of the extension you use to auto fill specific lines? Thanks!

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

      GitHub Copilot

  • @nosrehcorporation
    @nosrehcorporation 11 วันที่ผ่านมา

    Nice tutorrial, my only question is why Arcanine is not the first as it starts with A?

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

    Does anybody know what Jack is using that gives prompts when he starts typing? For example, for reduce function syntax at 33min.11sec? What VS extension is it?

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

    whats the extension he used? like when we want to type onClick function, the extension could show up the recomendation tag and symbol for typing the function.

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

    Thanks!

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

    Can someone explain to me what Jack does around the 31 minute mark with the {...state, ...action}. I understand the spread operator syntax, I just can't wrap my head around how this works with a more complex state. Like if I had an array of people with first & last name, how would this shortened reducer function know which values to change? I've spent an hour+ trying to work this out.

  • @BudetSvobodnoy
    @BudetSvobodnoy 5 วันที่ผ่านมา

    on 28:35 wouldn't it be better to use forEach instead of map? Since map creates a new array which is not necessary here

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

    Just after watching 15 mins, my mind be like 🤯😮‍💨 (how a man can make us to understand something into this level)

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

      @AKSHAY sorry I didn't get you..
      As well as I am from south India, so I didn't understand Hindi in code with harry videos

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

      @AKSHAY hey by the way, do you know any best react native course.. 😁

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

    I am getting duplicate keys error in the useState segment. I wish he'd have explained the reason for introducing that prop rather than just add it as if serves seome necessary functionality. It breaks the app. Also, even after calling a blank string on setName, the input field still doesn't refresh.

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

    I like the second implementation of useReducer hook but when I'm going to try with Typescript , I couldn't manage to implement. Is that my problem or is it possible to implement with Typescript ?

  • @chhavimanichoubey9437
    @chhavimanichoubey9437 9 หลายเดือนก่อน

    Pass by value vs pass by reference in terms of state, no one ever mentioned this in any video or blog tutorial I saw in my whole life.

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

    I like your teaching technic

  • @thomasstambaugh5181
    @thomasstambaugh5181 2 หลายเดือนก่อน +1

    The shift to Typescript at 1:13:53 significantly impairs the rest of the video. The noise of all that Typescript junk obfuscates the material I'm trying to absorb. I apparently have to go elsewhere to learn how to use "useContext", "createContext" and custom hooks in Javascript.

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

    Nice course

  • @gabrielsantini2841
    @gabrielsantini2841 10 หลายเดือนก่อน

    what nice place jack has to work, in the middle of the woods. I'd like have some place like that.