Is the React Native app updated in the iOS simulator equivalent to closing the app and reopening it?

I ask about this because when you hit cmd + r, all components will be set to their default state. To reproduce this using an application downloaded from the application store, could you close the application by double-clicking the home button, swipe the screen in the application, and then open it again?

I don’t have any apps in the store yet, so I can’t verify this.

Would storing the appropriate data in AsyncStorage good way to maintain state after a reboot?

For example: I have a registered user whose information is stored in a state. If I update the application, this user will be lost and forced to log in. However, if I save user information before AsyncStorage , and I can restore them according to componentDidMount .

+5
source share
1 answer

Updates the React Native app in the iOS simulator, equivalent to closing the app and reopening it?

No. Rebooting the application simply forces it to download the JS code again and run it from the entry point. The native part of the application never stops. This means that if you have your own custom logic, you will not restart it. From a practical point of view, rebooting is achieved by the same result as closing and opening the application.

Does AsyncStorage store relevant data in a good way to maintain state after a reboot?

Yes. No matter what you put in AsyncStorage , reboots will be saved, as well as closing and opening the application again. Only by explicitly deleting data or deleting the application will the saved data be deleted.

+3
source

Source: https://habr.com/ru/post/1262250/


All Articles