未处理的 JS 异常:不变冲突:使用 React-Redux Connect #15822 的钩子调用无效



我是本地反应的新手,我正在尝试在我的应用程序中实现 Redux。使用 react-redux 的连接函数时的反应原生抛出错误如下。

export default connect()(MyComponent);

我检查了所有 3 个选项,我没有破坏任何选项:

  1. 你可能有不匹配的 React 和渲染器版本(例如 React DOM(
  2. 你可能违反了钩子的规则(不确定(
  3. 您可能在同一应用程序中有多个 React 副本

下面列出的依赖项版本:

"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-native": "0.57.7",
"react-native-elements": "^0.19.1",
"react-native-geocoding": "^0.3.0",
"react-native-gesture-handler": "^1.0.12",
"react-native-maps": "https://github.com/react-community/react-native-maps.git",
"react-native-modal": "^9.0.0",
"react-native-router-flux": "^4.0.6",
"react-native-size-matters": "^0.1.4",
"react-native-super-grid": "^3.0.4",
"react-native-vector-icons": "^4.6.0",
"react-navigation": "^3.0.9",
"react-redux": "^7.0.3",
"redux": "^4.0.1",
"redux-logger": "^3.0.6"

当我删除连接((时错误消失。但它阻止了植入 Redux

这是 React Native 中的错误还是我在这里做错了什么?

尝试将 react-native 更新为 0.59.x。

看起来 react-redux 在内部切换到使用 React 钩子。但是 react-native 从版本 0.59 开始添加了 React 钩子支持(https://facebook.github.io/react-native/blog/2019/03/12/releasing-react-native-059(。

最新更新