用 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
然后我把 hook 里的 useState useRef 去掉就一个纯函数式组件。打包后再引用没问题!然后我又把组件直接放在项目里使用没有问题,唯独我组件中使用了 useState 打包引用就会报上面的错!还是说 hook 组件是不能用 webpack 打包发布的?