I just had a mind explosion moment when you showed the custom useState and useEffect hooks. It makes so much sense now why we can't use hooks anywhere but at the top level!
I did this very thing with useState so I reversed engineered it in my mind. I asked the same questions about the order and wondered how the counter could be incremented, and I concluded an array and global counter/index. Great work!
I've been looking on the react internal working in many resources, your content is the one that consolidate and visualize it greatly. great job! thanks a lot for all this hard work.
Amazing video. This was exactly what I was looking for, sadly I had to scroll several times as the top videos titled with “how react actually works” were all just shallow reiterations of the react API.. thank you!
Excellent tutorial. Only doubt remains is as to why React team decided to go with Arrays and indexes to store hooks. We could use objects and as long out component identifies correctly, hook can be retrieved reliably even if all hooks don't run.
Yes there is quite a difference. React uses Fibers under its hood (check out the previous video) and the implementation of useState is quite different in reality. If you want to learn more and perhaps see how useState can be implemented in React Fiber, check out pomb.us/build-your-own-react/
Especially if this is your first time seeing something like this it is completely fine, try to rewatch the video a few times or maybe sleep on it and then you will definitely understand it better