I am using react-navigation and when a user logs in, it redirects to Home screen. However, when I go back to Login, I can see the state is not reset. Basically, it is keeping state the same as I left when navigating to Home.
this.state = {
loading: false
};
Case explanation : when log in clicked, set loading
to true and go to home
screen. In Home
screen click Back
which redirects to Login
, where loading
is still set to True.
That seems odd, never experienced that. I thought react sets state on load.
question from:
https://stackoverflow.com/questions/65854582/why-login-page-doesnt-reset-state-when-navigating-to-home-page 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…