[英]Error Message: Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component
[英]Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component
我正在嘗試使用 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
上面的錯誤發生在組件中:in Provider (created by App) in ErrorBoundary (created by App) in App
包.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",
...
應用程序.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 以上嗎
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.