skip to Main Content

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.

enter image description here

This is the Error message that I am getting.

2

Answers


  1. 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'

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search