Understanding React Hooks by building them

Recently I started learning React after seeing all the hype around it. Frankly, I am yet to understand why developers are going JavaScript first way to build UI when in fact the more natural thing is HTML first to build UI and use Javascript to add interactivity.

But I really like how they have taken the concept of JavaScript closures to create [Hooks](https://reactjs.org/docs/hooks-intro.html)

Even after spending almost a decade writing JavaScript, I had hiccups while understanding how exactly the hooks concept work. How can a function have multiple React.useState calls and is able to figure out which useState call would return what?

To internalize how hooks work, I tried to re-create React.useState API.

You can access the implementation here

... Loading comments