expo: AsyncStorage state is lost when ejecting
If you have some data saved to AsyncStorage in your deployed managed workflow app, then when you eject and deploy that update it will search in the wrong path for the data.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (5 by maintainers)
@kevingarry97 - you’re using it wrong 😅 you can post to issues https://forums.expo.io for help. this issue is about something else entirely.
as of @react-native-async-storage/async-storage@1.15.0 this issue is resolved!
please do the following:
related prs: https://github.com/react-native-async-storage/async-storage/pull/563, https://github.com/react-native-async-storage/async-storage/pull/559
If you’re reading this and thinking if there’s an easy workaround, here goes nothing. (Use at your own risk)
https://gist.github.com/luizjr92/db091719f09617abc5909ba64485e395
Just make sure to replace your experience id on line 50
we plan on working on this during the sdk 41 cycle, so we should have a solution ready by april
@valentinbourqui I was in the same use case, migrating from vanilla React Native to expo in one of my app.
You’ll need that :
This is how I read vanilla storage on android and ios.
Thanks to other people in this page (and their gist).
It’s not the best code of the year but it works 😂
https://gist.github.com/rphlmr/8e7f864a792b67215f2e37a2cef099e3
Hope it helps 😃
Does anyone have a snippet for migrating the entire AsyncStorage database on Android?
We experienced this issue after ejecting from managed to a bare workflow.
On iOS AsyncStorage saves data in text files under
../Documents/RCTAsyncLocalStorage_V1, but Expo saves it in../Documents/RCTAsyncLocalStorage. On Android RN uses SQLite to back up the AsyncStorage. The database file is/data/data/<package_name>/databases/RKStorage, but Expo changed it name toRKStorage-scoped-experience-${encodeURIComponent(<experience-id>)}.To fix that on iOS we just renamed folder name using
expo-file-system:On Android, it’s not possible to copy or rename prefixed database with
expo-file-systemorreact-native-fs, and you will get error ‘file is not readable or movable’. So we used this solution: https://github.com/expo/expo/issues/2805#issuecomment-539502599@yaroslavnikiforov There is any way to use …/Documents/RCTAsyncLocalStorage_V1 for IOS and /data/data/<package_name>/databases/RKStorage for android with expo project ? I am currently in the opposite problem. My old application is an RN project and I want to use expo for the new one. Or is it better to use eject process and have back again default RN paths ?