调用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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM