未捕获错误:无效的钩子调用.钩子只能在函数组件的主体内部调用



我正试图用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

组件中出现上述错误:在提供程序中(由应用程序创建(在ErrorBoundary中(由应用程序创建(应用程序内

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

请帮助

你能将你的react dom更新到高于16.8.0 吗

相关内容

  • 没有找到相关文章

最新更新