useState in React is counting on the order in which it's called, inside a given component instance, to access values stored in global state. Since React is in control of it's own render cycle when React's useState is called, it has one piece of the lookup: The component instance. The other part comes from when useState is called (this is why you can't put it in a conditional). So. If you wanted to build this yourself, your useState would at least need to take in some unique identifier in place of the component instance. I hope that helps.
useState in React is counting on the order in which it's called, inside a given component instance, to access values stored in global state. Since React is in control of it's own render cycle when React's useState is called, it has one piece of the lookup: The component instance. The other part comes from when useState is called (this is why you can't put it in a conditional). So. If you wanted to build this yourself, your useState would at least need to take in some unique identifier in place of the component instance. I hope that helps.
Well, you're right. That's an extra layer I should be thinking of- I'll see what I can do. Thanks for your help!