【问题标题】:Redux-Persist not working on React-native@0.60.4Redux-Persist 不适用于 React-native@0.60.4
【发布时间】:2019-07-26 15:46:59
【问题描述】:

我已经使用 redux-persist 大约 6 个月了,它从未发生过,但这次在我的新项目中 redux-persist 不起作用,我不知道是什么原因。请注意,我不能降级,因为我必须重新退出项目,我不能这样做。需要快速修复。

任何帮助将不胜感激。谢谢。

我的 Package.json

      "dependencies": {
        "@ptomasroos/react-native-multi-slider": "^1.0.0",
        "@react-native-community/async-storage": "^1.5.1",
        "native-base": "2.12.1",
        "react": "16.8.6",
        "react-native": "0.60.4",
        "react-native-animatable": "^1.3.2",
        "react-native-calendar-picker": "^6.0.1",
        "react-native-calendar-strip": "^1.3.8",
        "react-native-calendars": "^1.200.0",
        "react-native-document-picker": "^3.2.4",
        "react-native-gesture-handler": "^1.3.0",
        "react-native-image-picker": "^1.0.1",
        "react-native-linear-gradient": "^2.5.4",
        "react-native-parallax-scroll-view": "^0.21.3",
        "react-native-permissions": "^1.2.0",
        "react-native-progress-bar-animated": "^1.0.6",
        "react-native-ratings": "^6.3.1",
        "react-native-render-html": "^4.1.2",
        "react-native-scaling-drawer": "^1.0.1",
        "react-native-snap-carousel": "^3.8.0",
        "react-native-splash-screen": "^3.2.0",
        "react-native-star-rating": "^1.1.0",
        "react-native-toast": "^1.0.1",
        "react-native-vector-icons": "^6.6.0",
        "react-native-wheel-picker-android": "^2.0.5",
        "react-navigation": "^3.11.1",
        "react-redux": "^7.1.0",
        "redux": "^4.0.4",
        "redux-persist": "5.6.12",
        "redux-thunk": "^2.3.0",
        "rn-range-slider": "^1.2.5"
      },
      "devDependencies": {
        "@babel/core": "7.5.5",
        "@babel/runtime": "7.5.5",
        "@react-native-community/eslint-config": "0.0.3",
        "babel-jest": "24.8.0",
        "eslint": "6.0.1",
        "jest": "24.8.0",
        "metro-react-native-babel-preset": "0.54.1",
        "react-test-renderer": "16.8.6"
      },
      "jest": {
        "preset": "react-native"
      }
    }

【问题讨论】:

  • 开发控制台有错误吗?
  • 没有错误,我在重新加载后收到我的初始状态意味着状态没有持续存在
  • 您是否尝试将redux-persist 升级到5.10.0 进行测试?
  • 是的,我正在使用最新的 RN,并且坚持

标签: react-native redux-persist


【解决方案1】:

我可以通过在 reduce 中添加 "persist/REHYDRATE" 操作来解决此问题,但是我不知道此操作的作用,但解决了我的问题

case "persist/REHYDRATE":{
 return{
    ...action.payload.global
  }
}

其中 global 是我的 reduce 的名称

【讨论】:

    猜你喜欢
    • 2018-05-23
    • 1970-01-01
    • 2018-07-20
    • 1970-01-01
    • 2019-10-22
    • 1970-01-01
    • 2017-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多