React tracks hooks in a specific order during each render of a component using a linked list of hooks tied to the component.
Conditional rendering of components does not interfere with state because each component's state is tracked independently via its node.
When a component is unmounted, React removes the component (and its associated state) entirely from its memory, and remounting creates a new component instance with fresh state.