QQ技术群:5678537,70210212,77813547 个人网站:http://www.lovewebgames.com 邮箱:55342775@qq.com

调用hook组件时报错Hooks can only be called inside of the body of a function component

在调用其他项目中的hook组件时,报错信息:无效的钩子调用。钩子只能在函数组件的主体内部调用。这可能是由于以下原因之一:

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://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

A库调用B,B使用的是npm link调试,会导致react的依赖出现两次,所以需要在B中link到A下面的react,重启项目

npm link G:\git\phoenix\node_modules\react
npm link G:\git\phoenix\node_modules\react-dom

 

posted @ 2021-06-28 16:42  田想兵  阅读(7517)  评论(0编辑  收藏  举报
联系QQ:55342775,QQ技术群:5678537,70210212,77813547 个人网站:http://www.lovewebgames.com 邮箱:55342775@qq.com