The Problem
I am migrating the logout functionality of my hybrid app from native to react native.
Requirements:
- It works in production and on a device
- It navigates to the root screen of the app (login screen)
- It clears the redux store
- [nice to have] It cancels any in-flight requests
Initially, we planned to do something like this: how-to-reset-the-state-of-a-redux-store
The Idea
As of React Native 0.62.0, we now have access to the DevSettings module. DevSettings has a native bridge that can reload the react-native environment. But are DevSettings really only for development environments?
Export the DevSettings module, add addMenuItem method (cc068b0551 by @janicduplessis)
The Question
- What are the tradeoffs for using reload vs logging out with a redux action?
- Should I use reload in a production app?
Edit: The Answer
- Reload is disallowed in prod (code)
- react-native-restart worked great for my use case.