简体   繁体   中英

How long does redux state persist in memory in react native

I am trying to understand how to manage redux state in my react-native app. In particular, I am trying to work out what happens when my app is minimized or the device is turned off.

With this knowledge I can then work out best how to persist state, and prepare for any illegal states that may arise from the redux state being reset.

Is it a fair assumption to make that if the redux state is reset, the entire app itself will restart (and therefore any initialization of the redux store will be called again?).

Is it a fair assumption to make that if the redux state is reset, the entire app itself will restart

This assumption is not true, however the inverse is. The redux state can be reset during runtime if there is code to do it via a reset action or otherwise.

However if the app is shut down, and the code re-runs it will be loaded with your default redux state.

AsyncStorage (in native) / localstorage for web, is often used in conjunction with redux in order to persist state across app crashes / browser sessions.

You can set AsyncStorage as a strategy for the redux-persist middleware (or write your own)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM