【发布时间】:2021-01-16 02:06:32
【问题描述】:
我正在尝试使用 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
组件出现上述错误: 在 Provider(由 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
请帮忙
【问题讨论】:
-
抱歉忘记了,在我最后的帖子里加了,谢谢
标签: javascript reactjs redux react-redux