-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Description
What happens?
如 issses#10270 问题。
umi4 模块联邦的接入方,远端模块报dispatcher找不到的错误。现在有解决方案了吗?
将 useModal 替换成 Valtio 成本有点大,如果没有其他方案才会考虑这个替换
Mini Showcase Repository(REQUIRED)
Please provide a minimal reproduction then upload to your GitHub. 请提供 最小重现,并上传到你的 GitHub 仓库
- 导出方
配置:
mf: {
name: 'mfAdminWeb',
// 配置 MF 共享的模块
shared: {
react: {
singleton: true,
eager: true,
requiredVersion: '^17.0.0',
},
'react-dom': {
singleton: true,
eager: true,
requiredVersion: '^17.0.0',
},
},
},
导出的组件:
import { useModel } from '@umijs/max';
- 接入方
配置:
mf: {
remotes: [
{
name: 'mfAdminWeb',
entry: 'http://localhost:8081/remote.js',
},
],
// 配置 MF 共享的模块
shared: {
react: {
singleton: true,
eager: true,
requiredVersion: '^17',
},
'react-dom': {
singleton: true,
eager: true,
requiredVersion: '^17',
},
},
},
3.接入的代码:
import { safeMfImport } from '@umijs/max';
const { HomepageVisualizer } = await safeMfImport('mfAdminWeb/components', {
default: null,
});
const App = ( ) => {
return (
<div>
<HomepageVisualizer />
</div>
);
}
4.结果
How To Reproduce
Context
- Umi Version: "@umijs/max": "^4.6.4"
- Node Version: v16.20.0
- Platform: Google Chrome 141.0.7390.108(正式版本) (arm64)
Metadata
Metadata
Assignees
Labels
No labels
