小编Gib*_*Dev的帖子

React 17.0.1:无效的钩子调用。钩子只能在函数组件体内调用

这里是非常新的反应用户。我已经解决这个错误几个小时了。我以前让这个组件作为一个类工作,但最近似乎每个人都在向功能组件迁移,所以我正在尝试转换它。我在不使用状态的情况下进行了中间转换,效果很好,但我在将用户名和密码转换为状态值时遇到了问题。

当我使用以下代码时,出现错误:

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
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
Run Code Online (Sandbox Code Playgroud)

我已多次阅读链接的故障排除页面,并尝试修复所有三个可能的原因,但没有成功。 …

npm reactjs eslint react-dom

7
推荐指数
1
解决办法
5万
查看次数

标签 统计

eslint ×1

npm ×1

react-dom ×1

reactjs ×1