未处理的JS异常:永久违反:使用React-Redux Connect的无效钩子调用#15822

时间:2019-06-04 20:42:56

标签: react-native redux react-redux

我是本机反应的新手,我正在尝试在我的应用程序中实现Redux。如下所述,在使用来自react-redux的connect函数时反应本机抛出错误。

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"

当我删除connect()时,错误消失了。但这阻止了Redux的植入

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

1 个答案:

答案 0 :(得分:1)

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

类似于react-redux的外观已切换为在内部使用React外观。但是react-native添加了从版本0.59(https://facebook.github.io/react-native/blog/2019/03/12/releasing-react-native-059)开始的React钩子支持。