How do React Hooks really work? Let's build useState from scratch!

Sdílet
Vložit
  • čas přidán 28. 03. 2021
  • Have you ever wondered how exactly React hooks work under the hood, and why they have the rules that they have? In this video we're going to answer those questions, by building our own useState hook completely from scratch. Let's get coding!
    👍 And remember to smash that like button! 💥
    ----------------------------------------------------------------------
    💌 Subscribe to my newsletter to be the first to know when I release new content, and for exclusive content: jacquesblom.com
    ----------------------------------------------------------------------
    🌐 Links
    The starter code: github.com/jacques-blom/react...
    Swyx's Egghead lesson: egghead.io/lessons/react-conc...
    ----------------------------------------------------------------------
    🐦 Follow me on Twitter: / jacques_codes
  • Věda a technologie

Komentáře • 32

  • @JacquesBlom
    @JacquesBlom  Před 3 lety +5

    Thanks so much for watching! 🙏 Feel free to leave any questions in the comments below and I'll do my best to get back to you.
    💌 Also be sure to subscribe to my newsletter to be the first to know when I release new content, and for exclusive content at jacquesblom.com​

  • @alanthomasgramont
    @alanthomasgramont Před 14 dny

    Why do you only have 1.5k subs? This was so interesting. Thank you.

  • @matheusviniciusandrade2733
    @matheusviniciusandrade2733 Před 4 měsíci +1

    One of the most interesting videos that I have ever seen.

  • @SilvioAmon
    @SilvioAmon Před 2 lety +6

    Finally someone was able to explain this well!

  • @ayush--gupta
    @ayush--gupta Před rokem

    This is not what I was looking for, but i am very thankful this much clearity of explanation. Really appreciate.

  • @santhoshj4081
    @santhoshj4081 Před rokem

    This is a great video, very well presented, thank you so much!

  • @niketanjha
    @niketanjha Před 2 lety +1

    Awesome ❤️ Subscribed.

  • @ayush612
    @ayush612 Před 2 lety

    Amaziiiiiingggg!!!! Thanks Jacques..so insightful!

  • @chandrapriya6618
    @chandrapriya6618 Před 2 lety

    Really wonderful!! Helped me in a state of confusion

  • @saisagarsharma
    @saisagarsharma Před 2 lety

    Dude u got very good presentational skills. U will rock. keep posting videos.

  • @electrotsmishar
    @electrotsmishar Před rokem

    thanks so much. very useful information

  • @pieter5466
    @pieter5466 Před rokem

    Great video, helps understand certain things many devs might take "as given".

  • @chrisschuller7055
    @chrisschuller7055 Před 2 lety

    Awesome video! So many people are just writing the code without explaining the last little bit of why you have to call the render method in the end. Now I understood how it works! :D

  • @SaidElnaffar
    @SaidElnaffar Před 2 lety +2

    I watched more than 3 videos and admittedly this is the most elegant code ever!

  • @zaeemAtif
    @zaeemAtif Před 13 dny

    That was pretty dang explanation

  • @ChandrikaChenna
    @ChandrikaChenna Před rokem

    Super!! Very useful

  • @SouravRakshit_srv
    @SouravRakshit_srv Před 3 lety +1

    too good😲 never had such deep dive into react, will definitely check the recoil content now

  • @abdelazizlaissaoui9079
    @abdelazizlaissaoui9079 Před 9 měsíci

    Great video we have just seen Great content creator

  • @michelreyes7375
    @michelreyes7375 Před 3 lety

    Thanks 😊 I also follow you on Learn Recoil and the way you explain make it thinks look easy-going.

  • @alexgavril385
    @alexgavril385 Před 7 měsíci

    🎉

  • @kellothermes9039
    @kellothermes9039 Před 2 lety +1

    I'm having trouble understanding why we need to freeze the currentIndex. Every time we re-render the App component the index would be set to -1 and then useState will be called twice. So, the call index would be 1 again. What is the point of setting the callIndex to -1 for every re-render? Could someone please explain it to me?

  • @rudboi
    @rudboi Před rokem +1

    Why does calling "renderApp" work inside setState? Aren't function expressions not hoisted? Or does it reside in memory after the first "render" ?

  • @infocampus5043
    @infocampus5043 Před rokem

    does ur useState accept prev=>prev+1 ??

  • @RandomGuy-jv4vd
    @RandomGuy-jv4vd Před 2 lety +1

    I'm just getting into React and i have this considerably naive question: why does setCount(countA + 1) works but not setCount(countA++) or setCount(++countA) ?

    • @negenalamjiyn6637
      @negenalamjiyn6637 Před 7 měsíci

      Still don't know or should I explain as I understand?

    • @RandomGuy-jv4vd
      @RandomGuy-jv4vd Před 7 měsíci

      @@negenalamjiyn6637 now looking back after 2 yrs, and have better understanding of the JS closure, I think a more appropriate setState in this case should be `setCount(prevCount => prevCount + 1)`

  • @allenjr4978
    @allenjr4978 Před 2 lety

    At 2.00 why are you declaring outside the function why not inside the function?

    • @SaidElnaffar
      @SaidElnaffar Před 2 lety +1

      He is right. At 2:00 he should declare the index and the array outside the useState function because they are global and common over the multiple calls of useState. If inside, then they will be re-initialized each time the useState is called, which is wrong.

  • @_Aries96
    @_Aries96 Před 10 měsíci

    i can't understand. so fast for me

  • @ahmadgazzz
    @ahmadgazzz Před 7 měsíci

    Doesn’t usestate use closures