keys do not persist between app reloads
See original GitHub issueCurrent behavior
Async Storage does not persist between app reloads
Expected behavior
expect the storage to persist between app reloads
Repro steps
Theory: It may be due to my environment. I am on RN 0.60.3 but link async-storage manually instead of relying on the auto-linking mechanic. Could this cause an issue?
Steps to reproduce:
-
store items in storage
await AsyncStorage.setItem('someItem', JSON.stringify(someItem));
-
retrieve items to ensure they have been stored
let keys = [];
try {
keys = await AsyncStorage.getAllKeys();
} catch (e) {
console.log('e', e);
// read key error
}
console.log(keys);
- reload application & look for keys
let keys = [];
try {
keys = await AsyncStorage.getAllKeys();
} catch (e) {
console.log('e', e);
// read key error
}
console.log(keys);
- The previously stored keys are no longer present.
Environment
do not use podfile, instead link react-native manually “@react-native-community/async-storage”: “^1.6.1” “react-native”: “0.60.3”
- occurs on both iOS and android
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:7 (1 by maintainers)
Top Results From Across the Web
keys do not persist between app reloads #184 - GitHub
I too am experiencing this issue the last few days - but only on iOS simulator (iOS 12.4). I only experience this intermittently...
Read more >5 Methods to Persisting State Between Page Reloads in React
One of the straightforward options is to use localStorage in the browser to persist the state. Let's take a look at an example....
Read more >How to Save State to LocalStorage & Persist on Refresh with ...
Step 3: Getting a stored value from localStorage and loading it into React state. Finally to make sure our state is persisted any...
Read more >Registry Keys not persisting after machine restarts
Is it possible that the program runs under a different after the computer starts up (i.e. system-account, since at that time no user...
Read more >Why is authentication lost after refreshing my single page ...
Common reasons are 1) Auth0 developer keys are being used instead of your own credentials for a social connection or 2) the browser...
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 FreeTop 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
Top GitHub Comments
I too am experiencing this issue the last few days - but only on iOS simulator (iOS 12.4). I only experience this intermittently when using
cmd+R
to reload the app on the simulator. When I presscmd+D
then click “Reload” in the simulator I never lose my AsyncStorage data?!“@react-native-community/async-storage”: “^1.6.1” “react-native”: “0.60.4”
@Krizzu Thanks! It was redux-persist. It seems that I need to set store manually to AsyncStorage.