react面试题hooks调⽤hook组件时报错Hookscanonlybecalledinsideofthebod。。
。
在调⽤其他项⽬中的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 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
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论