question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

keys do not persist between app reloads

See original GitHub issue

Current 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:

  1. store items in storage await AsyncStorage.setItem('someItem', JSON.stringify(someItem));

  2. 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);
  1. reload application & look for keys
let keys = [];
  try {
    keys = await AsyncStorage.getAllKeys();
  } catch (e) {
    console.log('e', e);
    // read key error
  }

  console.log(keys);
  1. 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:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
crobinson42commented, Aug 9, 2019

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 press cmd+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”

1reaction
MariuszSpeednetcommented, Aug 22, 2019

@Krizzu Thanks! It was redux-persist. It seems that I need to set store manually to AsyncStorage.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found