rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.94k stars 866 forks source link

storage.getItem is not a function (it is undefined) - RN 0.73.4 #1468

Closed Nader-CS closed 3 months ago

Nader-CS commented 7 months ago

WhatsApp Image 2024-02-22 at 12 57 58 AM

package.json

{
  "name": "unknown",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest",
    "postinstall": "patch-package",
    "clean": "watchman watch-del-all && rm -rf node_modules && yarn",
    "clean-android": "cd android && ./gradlew clean && cd ..",
    "clean-ios": "xattr -w com.apple.xcode.CreatedByBuildSystem true ./ios/build && cd ios && xcodebuild clean && cd ..",
    "clean-build": "yarn clean && yarn clean-android && yarn clean-ios",
    "bundle": "cd android && ./gradlew bundleRelease && cd .."
  },
  "dependencies": {
    "@bam.tech/react-native-image-resizer": "^3.0.5",
    "@gorhom/bottom-sheet": "^4.5.1",
    "@mahmoudaliibrahim/react-native-loading-view": "^1.0.8",
    "@marqroldan/react-native-geocoder": "^1.1.0",
    "@notifee/react-native": "^7.8.0",
    "@react-native-async-storage/async-storage": "^1.19.1",
    "@react-native-community/blur": "^4.3.2",
    "@react-native-community/checkbox": "^0.5.16",
    "@react-native-community/geolocation": "^3.0.6",
    "@react-native-community/hooks": "^3.0.0",
    "@react-native-community/netinfo": "^9.4.1",
    "@react-native-firebase/analytics": "^18.3.0",
    "@react-native-firebase/app": "^18.3.0",
    "@react-native-firebase/crashlytics": "^18.3.0",
    "@react-native-firebase/messaging": "^18.3.0",
    "@react-navigation/bottom-tabs": "^6.5.8",
    "@react-navigation/native": "^6.1.8",
    "@react-navigation/stack": "^6.3.17",
    "@reduxjs/toolkit": "^1.9.5",
    "@tap-payments/apple-pay-rn": "^0.1.3",
    "@tap-payments/gosell-sdk-react-native": "^1.0.3-5.alpha.0",
    "@th3rdwave/react-navigation-bottom-sheet": "^0.2.7",
    "babel-plugin-dotenv-import": "^3.0.1",
    "i18next": "^23.2.11",
    "lodash.debounce": "^4.0.8",
    "moment": "^2.29.4",
    "react": "18.2.0",
    "react-i18next": "^13.0.2",
    "react-native": "0.73.4",
    "react-native-animatable": "^1.3.3",
    "react-native-appsflyer": "^6.12.2",
    "react-native-bootsplash": "^5.0.4",
    "react-native-calendar-picker": "^7.1.4",
    "react-native-camera": "^4.2.1",
    "react-native-chart-kit": "^6.12.0",
    "react-native-code-push": "^8.1.0",
    "react-native-collapsible": "^1.6.1",
    "react-native-config": "^1.5.1",
    "react-native-confirmation-code-field": "^7.3.1",
    "react-native-countdown-timer-hooks": "^1.0.4",
    "react-native-date-picker": "^4.2.13",
    "react-native-dropdown-picker": "^5.4.6",
    "react-native-file-viewer": "^2.1.5",
    "react-native-flipper": "^0.211.1",
    "react-native-gesture-handler": "^2.12.0",
    "react-native-google-places-autocomplete": "^2.5.5",
    "react-native-haptic-feedback": "^2.0.3",
    "react-native-html-to-pdf": "^0.12.0",
    "react-native-image-picker": "^5.0.2",
    "react-native-in-app-review": "^4.3.3",
    "react-native-maps": "^1.7.1",
    "react-native-maps-directions": "^1.9.0",
    "react-native-mmkv": "^2.10.1",
    "react-native-modal": "^13.0.1",
    "react-native-pager-view": "^6.2.1",
    "react-native-permissions": "^4.1.1",
    "react-native-progress": "^5.0.1",
    "react-native-qrcode-scanner": "^1.5.5",
    "react-native-qrcode-svg": "^6.2.0",
    "react-native-ratings": "^8.1.0",
    "react-native-reanimated": "^3.3.0",
    "react-native-render-html": "^6.3.4",
    "react-native-restart": "^0.0.27",
    "react-native-safe-area-context": "^4.7.1",
    "react-native-screens": "^3.22.1",
    "react-native-secure-key-store": "^2.0.10",
    "react-native-share": "^9.2.3",
    "react-native-simple-radio-button": "^2.7.4",
    "react-native-size-matters": "^0.4.0",
    "react-native-snackbar": "^2.6.2",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-svg": "^13.10.0",
    "react-native-system-setting": "^1.7.6",
    "react-native-tab-view": "^3.5.2",
    "react-native-toast-message": "^2.1.6",
    "react-native-vector-icons": "^10.0.0",
    "react-native-version-check": "^3.4.7",
    "react-native-video": "^5.2.1",
    "react-native-webview": "^13.3.1",
    "react-redux": "^8.1.1",
    "react-simple-form-validator": "^0.3.1",
    "redux-flipper": "^2.0.2",
    "redux-logger": "^3.0.6",
    "redux-persist": "^6.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "^0.73.21",
    "@react-native/eslint-config": "0.73.2",
    "@react-native/metro-config": "0.73.4",
    "@react-native/typescript-config": "0.73.1",
    "@tsconfig/react-native": "^3.0.0",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "babel-plugin-module-resolver": "^5.0.0",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "metro-react-native-babel-preset": "0.76.7",
    "patch-package": "^8.0.0",
    "prettier": "2.8.8",
    "react-native-obfuscating-transformer": "^1.0.0",
    "react-native-url-polyfill": "^2.0.0",
    "react-test-renderer": "18.2.0",
    "reactotron-react-native": "^5.0.3",
    "reactotron-redux": "^3.1.3",
    "seamless-immutable": "^7.1.4",
    "typescript": "5.0.4"
  },
  "resolutions": {
    "react-native-permissions": "^3.8.0"
  },
  "overrides": {
    "react-native-qrcode-scanner": {
      "react-native-permissions": "^3.8.0"
    }
  },
  "engines": {
    "node": ">=18"
  },
  "reactNativePermissionsIOS": [
    "Camera",
    "Notifications",
    "AppTrackingTransparency",
    "LocationWhenInUse"
  ]
}
Nader-CS commented 7 months ago

solution : removing package and re-installing it again solved the problem !

sovetski commented 7 months ago

@Nader-CS you can close the issue if it is solved for you

andriemc commented 6 months ago

I just made my own storage and it worked so idk

Here's an example if you need it (TypeScript + Web):

const storage: Storage = {
    async getItem(key) {
        return localStorage.getItem(key);
    },
    async setItem(key, value: string) {
        return localStorage.setItem(key, value);
    },
    async removeItem(key) {
        return localStorage.removeItem(key);
    },
};
silviodaminatoK commented 3 months ago

I had the same problem, @andriemc 's answer helped me in realising that the methods must be asynchronous.