Reactjs 错误:无效的钩子调用错误,即使我已重置为上一次提交

Reactjs 错误:无效的钩子调用错误,即使我已重置为上一次提交,reactjs,react-hooks,Reactjs,React Hooks,我已经使用REACT有一段时间了,我可以正确地使用钩子,并且没有违反任何钩子规则。出于某种原因,我执行了npm安装来重新安装所有软件包,之后,我遇到了这个错误 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 misma

我已经使用REACT有一段时间了,我可以正确地使用钩子,并且没有违反任何钩子规则。出于某种原因,我执行了npm安装来重新安装所有软件包,之后,我遇到了这个错误

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
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
我也确实重置为上一次提交,以放弃所有更改,但错误仍然存在

这是我的package.json文件

{
  "name": "client",
  "proxy": "http://127.0.0.1:5000",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.11.3",
    "@material-ui/lab": "^4.0.0-alpha.57",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "axios": "^0.21.1",
    "bootstrap": "^4.6.0",
    "mdbreact": "^5.0.1",
    "react": "^17.0.1",
    "react-bootstrap": "^1.5.1",
    "react-dom": "^17.0.1",
    "react-redux": "^7.2.2",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.3",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "uninstall-all-modules": "^1.0.5",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "npm run watch:css && react-scripts start",
    "build": "npm run build:css && react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "build:css": "postcss src/assets/tailwind.css -o src/assets/main.css",
    "watch:css": "postcss src/assets/tailwind.css -o src/assets/main.css"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "autoprefixer": "^10.2.4",
    "postcss": "^8.2.6",
    "postcss-cli": "^8.3.1",
    "tailwindcss": "^2.0.3"
  }
}
所有软件包都是最新的,我们正在进行此特定的提交


类似错误的其他答案似乎都无法解决我的问题,最糟糕的是我甚至无法找出错误的根源。如果需要其他信息,请在评论中提及。

此问题并不总是与挂钩的使用或任何其他错误有关。
这次是因为我使用了一个模块“mdbreact”。由于某些原因,他们的网站已关闭,如果您的项目使用它,您将最终收到此错误。

请运行
npm list--depth=0
并比较
react
react dom
的安装版本。它们必须匹配。@trixn是的,它们匹配
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
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.