qiankun icon indicating copy to clipboard operation
qiankun copied to clipboard

[Bug]手动加载用hook写的子应用,主应用报错

Open snaketzy opened this issue 3 years ago • 3 comments

遇到的问题?

主应用为[email protected],hook 子应用为[email protected],hook

子应用以组件形式暴露给主应用,主应用加载后渲染报错

react-dom.development.js:14721 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

复现步骤,错误日志以及相关配置

在官方demo上测试

相关环境信息

qiankun: 2.4.9 chrome: 102

snaketzy avatar Jun 08 '22 21:06 snaketzy

报错很明显了,hook 不支持这么用,与qiankun无关,react限制了

gongshun avatar Jun 09 '22 06:06 gongshun

@gongshun 那么请问有解决方案么?目前项目里面的组件都是hook写的

snaketzy avatar Jun 10 '22 01:06 snaketzy

@gongshun 那么请问有解决方案么?目前项目里面的组件都是hook写的

没有办法,react 限制了,可以试下主子应用使用同一份 react 依赖

gongshun avatar Jun 16 '22 01:06 gongshun

Since the issue was labeled with out-of-scope, but no response in 30 days. This issue will be close. If you have any questions, you can comment and reply. 由于该 issue 被标记为与本项目无关,却 30 天未收到回应。现关闭 issue,若有任何问题,可评论回复。

github-actions[bot] avatar Sep 13 '22 00:09 github-actions[bot]