我试图在模块联合(webpack 5 功能)的帮助下在运行时获得一个动态系统。一切都很好,但是当我将钩子添加到“生产者”模块(主机应用程序从中动态导入组件的模块)时,我收到大量“无效的钩子规则”错误。
Warning: Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see [LINK RULES OF HOOKS]
Run Code Online (Sandbox Code Playgroud)
Warning: React has detected a change in the order of Hooks called by PluginHolder. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: [LINK RULES OF HOOKS]
Run Code Online (Sandbox Code Playgroud)
我已经使用了 externals 字段并在 html 文件中添加了 script 标签,我使用了共享选项来添加 singleton …