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

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

Jacques Blom

3 года назад

12,599 Просмотров

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: https://jacquesblom.com

----------------------------------------------------------------------

🌐 Links
The starter code: https://github.com/jacques-blom/react-hooks-from-scratch
Swyx's Egghead lesson: https://egghead.io/lessons/react-concurrent-react-from-scratch

----------------------------------------------------------------------

🐦 Follow me on Twitter: https://twitter.com/jacques_codes
Ссылки и html тэги не поддерживаются


Комментарии:

@michelreyes7375
@michelreyes7375 - 30.03.2021 02:24

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

Ответить
@SouravRakshit_srv
@SouravRakshit_srv - 30.03.2021 09:37

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

Ответить
@RandomGuy-jv4vd
@RandomGuy-jv4vd - 28.09.2021 12:28

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) ?

Ответить
@allenjr4978
@allenjr4978 - 25.10.2021 09:34

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

Ответить
@niketanjha
@niketanjha - 09.12.2021 23:21

Awesome ❤️ Subscribed.

Ответить
@SaidElnaffar
@SaidElnaffar - 26.12.2021 20:17

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

Ответить
@kellothermes9039
@kellothermes9039 - 12.01.2022 04:23

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?

Ответить
@SilvioAmon
@SilvioAmon - 02.02.2022 14:01

Finally someone was able to explain this well!

Ответить
@chrisschuller7055
@chrisschuller7055 - 04.02.2022 12:22

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

Ответить
@chandrapriya6618
@chandrapriya6618 - 24.03.2022 10:48

Really wonderful!! Helped me in a state of confusion

Ответить
@saisagarsharma
@saisagarsharma - 10.04.2022 07:18

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

Ответить
@ayush612
@ayush612 - 15.05.2022 12:01

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

Ответить
@rudboi
@rudboi - 24.10.2022 15:55

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

Ответить
@ChandrikaChenna
@ChandrikaChenna - 01.12.2022 11:03

Super!! Very useful

Ответить
@infocampus5043
@infocampus5043 - 09.03.2023 11:56

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

Ответить
@santhoshj4081
@santhoshj4081 - 03.05.2023 08:18

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

Ответить
@electrotsmishar
@electrotsmishar - 11.06.2023 07:25

thanks so much. very useful information

Ответить
@ayush--gupta
@ayush--gupta - 10.07.2023 20:18

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

Ответить
@pieter5466
@pieter5466 - 29.07.2023 21:24

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

Ответить
@_Aries96
@_Aries96 - 20.09.2023 07:27

i can't understand. so fast for me

Ответить
@abdelazizlaissaoui9079
@abdelazizlaissaoui9079 - 27.10.2023 00:02

Great video we have just seen Great content creator

Ответить
@ahmadgazzz
@ahmadgazzz - 25.12.2023 17:31

Doesn’t usestate use closures

Ответить
@alexgavril385
@alexgavril385 - 05.01.2024 04:47

🎉

Ответить
@matheusviniciusandrade2733
@matheusviniciusandrade2733 - 28.03.2024 06:18

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

Ответить
@alanthomasgramont
@alanthomasgramont - 20.07.2024 11:21

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

Ответить
@zaeemAtif
@zaeemAtif - 21.07.2024 19:55

That was pretty dang explanation

Ответить