我正在尝试使用redux启动一个react项目,但是我得到了
错误:
Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
----
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
上述错误发生在组件中: 在提供程序中(由App创建) 在ErrorBoundary中(由App创建) 在应用程序中
Package.json
"@babel/polyfill": "^7.11.5",
"@babel/preset-env": "^7.10.3",
"@babel/preset-react": "^7.10.1",
"axios": "^0.20.0",
"babel-core": "^7.0.0-0",
"babel-jest": "^26.3.0",
"babel-loader": "7.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "6.24.1",
"babel-register": "^6.26.0",
"img-loader": "2.0.0",
"jsdom": "10.1.0",
"mocha": "3.3.0",
"mocha-image-compiler": "1.0.0",
"prop-types": "15.6.0",
"react": "16.13.1",
"react-dom": "16.2.0",
"react-redux": "^7.2.1",
"react-render-html": "^0.6.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.3",
...
App.js
class App extends Component {
render () {
// console.log('This is app.js inside render');
return (
<ErrorBoundary>
<Provider store={store}>
<Routes />
</Provider>
</ErrorBoundary>
)
}
}
export default App
请帮助
答案 0 :(得分:1)
您能否将您的反应范围更新为高于16.8.0