How does React remember which state variable belongs to which useState call?
React relies on the order in which the useState (and other hooks) are called. It keeps track of the hooks based on the order they are called within the component during each render.