【问题标题】:React Native + Redux Orm Could not find "store" in either the context or props of "Connect (screenshot)React Native + Redux Orm 在“Connect”的上下文或道具中找不到“store”(截图)
【发布时间】:2017-07-14 02:43:02
【问题描述】:

我遇到了多个关于此的主题,但未能找到解决方案。其中大部分用于网络应用程序。我将不胜感激任何帮助。谢谢寻找。

I have created a repo for my code.

package.json

  "dependencies": {
    "lodash": "^4.17.4",
    "native-base": "^2.2.1",
    "react": "16.0.0-alpha.12",
    "react-native": "0.46.1",
    "react-native-firebase": "^2.0.2",
    "react-native-navigation": "^1.1.134",
    "react-redux": "^5.0.5",
    "redux": "^3.7.1",
    "redux-orm": "^0.9.4",
    "redux-persist": "^4.8.2",
    "redux-thunk": "^2.2.0"
  },
  "devDependencies": {
    "babel-jest": "20.0.3",
    "babel-preset-react-native": "2.1.0",
    "jest": "20.0.4",
    "react-test-renderer": "16.0.0-alpha.12",
    "redux-immutable-state-invariant": "^2.0.0",
    "redux-logger": "^3.0.6",
    "redux-orm-proptypes": "^0.1.0"
  },
  "jest": {
    "preset": "react-native",
    "verbose": true,
    "testPathIgnorePatterns": [
      "/node_modules/",
      "__tests__/factories",
      "__tests__/utils"
    ]
  }

【问题讨论】:

    标签: firebase react-native redux react-native-navigation


    【解决方案1】:

    src/main.js 中,<Provider> 的初始渲染是使用构造函数设置的默认this.state.store 调用的,即null

    相反,创建 store 并将其作为 props 传递给您的 <Root> 组件,因此它始终具有值。或者在构造函数中创建商店(不太好,但会工作)

    【讨论】:

    • 非常感谢您的回答。不幸的是,我不明白。对不起。我在main.jscomponentDidMount() 函数中有setState,它在我的store/setup.js 中调用setup 函数,所以我仍然对你的答案感到迷茫。如果有帮助,那就是mostly from this repo。我很感激你的回答。谢谢
    • componentDidMount 在初始渲染后触发。查看 React 生命周期 facebook.github.io/react/docs/react-component.html
    猜你喜欢
    • 2016-04-30
    • 1970-01-01
    • 2017-11-11
    • 1970-01-01
    • 1970-01-01
    • 2018-10-08
    • 2023-02-26
    • 2018-08-02
    • 2018-10-06
    相关资源
    最近更新 更多