|
|
|
|
|
by acemarke
2797 days ago
|
|
The first time the component renders, each individual call to `useState` results in a new unique-to-that-component state value being stored behind the scenes. React builds a linked list of all hooks attached to that function component the first time you run it, and then reads from that linked list in future re-renders. So, when you run it again, and `useState()` call #1 occurs, it reads the value and the setter function off the first linked list node, and returns those. |
|
What's saved in lines of code is lost in expressiveness.
Feels like a step toward Ruby-like magic.