react-native-async-storage / async-storage

An asynchronous, persistent, key-value storage system for React Native.
https://react-native-async-storage.github.io/async-storage/
MIT License
4.61k stars 458 forks source link

AsyncStorage is automatically cleared when the app is restarted #1093

Closed Inalegwu closed 1 month ago

Inalegwu commented 1 month ago

What happened?

While working with AsyncStorage, All information I've saved is automatically cleared from the app when it is closed or restarted, Both in Production and Development.

Version

1.21.0

What platforms are you seeing this issue on?

System Information

System:
  OS: Windows 11 10.0.22631
  CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
  Memory: 710.92 MB / 7.83 GB

Binaries:
  Node:
    version: 21.7.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn: Not Found
  npm:
    version: 10.5.0
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found

SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    Versions:
      - 10.0.22621.0
IDEs:
  Android Studio: Not Found
  Visual Studio: Not Found

Languages:
  Java: Not Found
  Ruby: Not Found

npmPackages:
  "@react-native-community/cli": Not Found 
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.6
    wanted: 0.73.6
  react-native-windows: Not Found

npmGlobalPackages:
  "*react-native*": Not Found

Android:
  hermesEnabled: Not found
  newArchEnabled: Not found

iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Steps to Reproduce

In a freshly created React Native project , after installing AsyncStorage and setting data using

AsyncStorage.setItem(key,value)

restart said app and try

console.log(await AsyncStorage.getItem(key))

it returns undefined

ghost commented 1 month ago

I tried to reproduce the error but worked completely fine, just wrapped the console.log(await AsyncStorage.getItem(key)) in a async function.

krizzu commented 1 month ago

Hey, if you could provide me a repo with a project where the issue can be reproduced, that'd be great