How do React Hooks really work? Let's build useState from scratch!
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
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
Why do you only have 1.5k subs? This was so interesting. Thank you.
One of the most interesting videos that I have ever seen.
Finally someone was able to explain this well!
This is not what I was looking for, but i am very thankful this much clearity of explanation. Really appreciate.
This is a great video, very well presented, thank you so much!
Awesome ❤️ Subscribed.
Amaziiiiiingggg!!!! Thanks Jacques..so insightful!
Really wonderful!! Helped me in a state of confusion
Dude u got very good presentational skills. U will rock. keep posting videos.
thanks so much. very useful information
Great video, helps understand certain things many devs might take "as given".
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
I watched more than 3 videos and admittedly this is the most elegant code ever!
That was pretty dang explanation
Super!! Very useful
too good😲 never had such deep dive into react, will definitely check the recoil content now
Thanks, Sourav!
Great video we have just seen Great content creator
Thanks 😊 I also follow you on Learn Recoil and the way you explain make it thinks look easy-going.
Thanks so much, Michel!
🎉
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?
Why does calling "renderApp" work inside setState? Aren't function expressions not hoisted? Or does it reside in memory after the first "render" ?
does ur useState accept prev=>prev+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) ?
Still don't know or should I explain as I understand?
@@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)`
At 2.00 why are you declaring outside the function why not inside the function?
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.
i can't understand. so fast for me
Doesn’t usestate use closures