News for hackers. Stuff that matters.
Re:Introducing Hooks by ajcodez on Thursday October 25, 2018 @11:21PM (#18306518)
Agreed it’s implicit. I think it works by keeping track of start and end of Component rendering and counting the function calls to useState in between. You can imagine the following sequence of events.

- Enter Component A

- Use State A0 (does not exist, set default value)

- Exit Component A

Where calling setA0 sets the value at index 0 for Component instance A and queues render again.

- Enter Component A

- Use State A0 (has existing value)

- Exit Component A

There are no comments on this comment yet.