Upgrading to Expo SDK 48 results in RCTAsyncStorage error

Please provide the following:

  1. SDK Version: 48
  2. Platforms(Android/iOS/web/all): iOS

I upgraded to Expo SDK 48 and am getting the following error:

Invariant Violation: RCTAsyncStorage not available

This error is located at:

in PhoneNumberFlow (created by App)

in ReferringUserIdContextProvider (created by App)

in App (created by withDevTools(App))

in withDevTools(App)

in RCTView (created by View)

in View (created by AppContainer)

in RCTView (created by View)

in View (created by AppContainer)

in AppContainer

in main(RootComponent), js engine: hermes

I am confused why I am getting this error, because I am not using AsyncStorage from the ‘react-native’ library. Instead, I am using AsyncStorage from the ‘@react-native-async-storage/async-storage’ library.

Here is my package:

{
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "android-build": "eas build --platform android"
  },
  "dependencies": {
    "@apollo/client": "^3.3.8",
    "@babel/runtime": "^7.20.13",
    "@config-plugins/react-native-branch": "^6.0.0",
    "@expo/config-plugins": "~6.0.0",
    "@foursquare/pilgrim-sdk-react-native": "^1.2.1",
    "@gorhom/bottom-sheet": "^4",
    "@react-native-async-storage/async-storage": "^1.19.3",
    "@react-native-clipboard/clipboard": "^1.11.2",
    "@react-native-community/datetimepicker": "6.5.2",
    "@react-native-community/hooks": "^2.6.0",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-picker/picker": "2.4.8",
    "@react-navigation/bottom-tabs": "^6.2.0",
    "@react-navigation/native": "^6.0.14",
    "@react-navigation/native-stack": "^6.9.2",
    "@react-navigation/stack": "^6.3.9",
    "@segment/analytics-react-native": "^2.10.0",
    "@segment/sovran-react-native": "^0.4.5",
    "@sentry/react-native": "4.9.0",
    "@shopify/flash-list": "1.3.1",
    "apollo-link-ws": "^1.0.20",
    "axios": "^0.21.1",
    "expo": "~48.0.18",
    "expo-application": "~5.1.1",
    "expo-av": "~13.2.1",
    "expo-blur": "~12.2.2",
    "expo-clipboard": "~4.1.2",
    "expo-constants": "~14.2.1",
    "expo-contacts": "~12.0.1",
    "expo-crypto": "~12.2.1",
    "expo-dev-client": "~2.2.1",
    "expo-device": "~5.2.1",
    "expo-file-system": "~15.2.2",
    "expo-image-manipulator": "~11.1.1",
    "expo-image-picker": "~14.1.1",
    "expo-linear-gradient": "~12.1.2",
    "expo-linking": "~4.0.1",
    "expo-location": "~15.1.1",
    "expo-media-library": "~15.2.3",
    "expo-notifications": "~0.18.1",
    "expo-sharing": "~11.2.2",
    "expo-sms": "~11.2.1",
    "expo-splash-screen": "~0.18.2",
    "expo-status-bar": "~1.4.4",
    "expo-store-review": "~6.2.1",
    "expo-system-ui": "~2.2.1",
    "expo-updates": "~0.16.4",
    "firebase": "8.2.3",
    "graphql": "^15.5.0",
    "leven-sort": "^4.0.0",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "react-instantsearch-hooks": "^6.39.2",
    "react-instantsearch-native": "^6.39.0",
    "react-native": "0.70.5",
    "react-native-branch": "^5.4.0",
    "react-native-confetti-cannon": "^1.5.2",
    "react-native-draggable-flatlist": "^4.0.0",
    "react-native-dropdown-picker": "^5.4.4",
    "react-native-expo-pie-chart": "^1.0.0",
    "react-native-gesture-handler": "^2.12.1",
    "react-native-get-random-values": "^1.9.0",
    "react-native-google-mobile-ads": "^7.0.1",
    "react-native-google-places-autocomplete": "^2.5.1",
    "react-native-hyperlink": "^0.0.22",
    "react-native-maps": "1.3.2",
    "react-native-paper": "^4.11.2",
    "react-native-progress": "^5.0.0",
    "react-native-purchases": "4.6.2",
    "react-native-reanimated": "^3.4.2",
    "react-native-safe-area-context": "4.5.0",
    "react-native-screens": "~3.20.0",
    "react-native-share": "^8.2.0",
    "react-native-size-matters": "^0.4.0",
    "react-native-svg": "13.4.0",
    "react-native-svg-charts": "^5.4.0",
    "react-native-svg-transformer": "^1.0.0",
    "react-native-view-shot": "3.4.0",
    "react-native-web": "~0.18.7",
    "react-navigation": "^4.4.4",
    "sentry-expo": "~6.0.0",
    "subscriptions-transport-ws": "^0.9.18",
    "typescript": "^4.9.3",
    "typesense": "^1.4.4",
    "typesense-instantsearch-adapter": "^2.5.0",
    "victory-native": "^36.6.8"
  },
  "devDependencies": {
    "@babel/core": "^7.19.3",
    "@types/react": "~18.0.24",
    "@types/react-native": "~0.70.6"
  },
  "private": true,
  "name": "simmer2",
  "version": "1.0.0"
}

I am only calling AsyncStorage once like the following:

import AsyncStorage from '@react-native-async-storage/async-storage';

export const storeData = async (storage_key, value) => {
    const jsonValue = JSON.stringify(value)
    try {
      await AsyncStorage.setItem(storage_key, jsonValue)
    } catch (e) {
      console.log("storeData error", e);
    }
}

export const getData = async (storage_key) => {
    try {
        const jsonValue = await AsyncStorage.getItem(storage_key)
        return jsonValue != null ? JSON.parse(jsonValue) : null;
    } catch(e) {
        console.log("getData error", e);
        return null;
    }
  }
  

Let me know if you have any suggestions!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.