How to reset Navigation states ?
See original GitHub issueI want to mimic ReactNavigation switch navigator
behavior that resets the routes to the default states after navigating away from it (for example after the user logs in/out). How can I do that ?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How do I reset a screens state to its initial state when using ...
I want to reset the state (back to initial state) in a functional component when navigated via navigation.navigate() .
Read more >React Navigation re-render / reset previous page's state on ...
React Navigation re-render / reset previous page's state on navigation or goBack ... TimeSaver: (If you understand the title, go to the SOLUTION:...
Read more >CommonActions reference - React Navigation
The reset action allows to reset the navigation state to the given state. It takes the following arguments: ... The state object specified...
Read more >reset navigation state crashes on Android #10148 - GitHub
I want to reset navigation state and navigate the user to the SignInScreen when user press the Logout button in the ProfileScreen ....
Read more >How to use the react-navigation.NavigationActions.reset ...
setState({ pwd: stringToU8("000000000000000000000000") }); // Removing it's refs do the GC can clean it delete this.state.pwd; // Construct a reset action for ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It works! I’ll close this for now. Thanks for the quick reply!!!
Ahh, thanks for providing a more detailed explanation. I understand exactly what you mean now.
I suggest you add a React
key prop
to yourMainScreen
component. If React detects that thekey
has changed then it will clear all the state from the component tree, for example, the selected tab.After the sign in process is finished, when you navigate to the
MainScreen
pass a differentclear
value to reset theMainScreen