I need to delete an item in AsyncStorage in my react native app on instance close of the app. How can I do that?
Asked
Active
Viewed 1,764 times
1
-
You can't run tasks when the app is closed. You'll need to write native Java, Swift/Obj-C code to achieve this functionality. The best workaround is not to save something to AsyncStorage if you don't want it to persist between app reloads. – Faisal Arshed Mar 07 '19 at 13:47
-
https://stackoverflow.com/questions/47571976/how-to-remove-an-item-from-asyncstorage-in-react-native @m9m9m refer it... – Saravana Kumar Mar 07 '19 at 14:05
-
@fsociety, thanks for the reply. If not AsyncStorage, what other options do we have to save some data to save and access only when the app is running and remove when instance is closing? – m9m9m Mar 08 '19 at 04:44
-
You can use state to hold the data while the app is running. The state will reset when the app is closed. And if you want your state to be centralized and accessible by all components, you can use Redux. – Faisal Arshed Mar 08 '19 at 05:48