I was trying to Upgrade my Expo SDK 46 to 48 – following the steps on Midium- https://blog.expo.dev/expo-sdk-48-ccb8302e231 but after following the upgrading commands, I started getting ERROR Invariant Violation: AsyncStorage has been removed from react-native core
Does anyone know how to fix this Error?
Thank you for your help in advance.
This is the Error message that I am getting.
2
Answers
As mentioned by Naveed above in comment. You most likely have an import in one of your js/ts files causing the error since AsyncStorage is no longer in React-Native.
This import is wrong:
import { AsyncStorage } from 'react-native'
Make sure you have @react-native-async-storage/async-storage installed by following instructions here: https://react-native-async-storage.github.io/async-storage/docs/install/
Then change all imports from:
import { AsyncStorage } from 'react-native'
to
import AsyncStorage from '@react-native-async-storage/async-storage'
In my case, I am using redux-offline, after digging through my node_modules I found that this package is using the deprecated AsyncStorage usage.
If you find a library in node modules is an offender it may be as simple as upgrading it, or in the case of redux-offline, patching it.