Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
489 views
in Technique[技术] by (71.8m points)

react native - Why Login page doesn't reset state when navigating to Home page?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...