3 ms·
> React state is scoped to the outer-most box, that way it doesn't change on every render The state (of the hooks) for individual components are still scoped t
by wjmao88 6y ago
> React state is scoped to the outer-most box, that way it doesn't change on every render
The state (of the hooks) for individual components are still scoped to that component only, its just stored in the "outer-most box", and the structure corresponds to the component tree. If a component unmounts and remounts, the prior state is lost.
- obedm 6y agoYou're correct, this is something I tried to convey in my article but I didn't want to spend too many words on it. When retrospecting about it, I realized I didn't think of it this way, even though it's correct. My mental model is like "state is just kept, don't worry about it". Thank you for pointing it out though, it's hard to be accurate and succinct