My simplest technology advice may be the most effective: when in doubt, turn it off and on again.
State is difficult to manage, as anyone who has worked with React knows. The technical explanation doesn't matter, though. When in doubt, turn it off and on again.