Skip to content

Commit

Permalink
fix: 增加 ssr render 后,处理 qiankun 的生命周期
Browse files Browse the repository at this point in the history
  • Loading branch information
bravepg committed Apr 18, 2024
1 parent 47987b1 commit 4b375ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/plugins/libs/qiankun/master/masterRuntimePlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ function patchMicroAppRouteComponent(routes: any[]) {
}

export async function render(oldRender: typeof noop) {
// 在 ssr 的场景下,直接返回旧的 render
if (typeof window === 'undefined') {
return oldRender();
}
const runtimeOptions = await getMasterRuntime();
let masterOptions: MasterOptions = {
...getMasterOptions(),
Expand Down
4 changes: 4 additions & 0 deletions packages/plugins/libs/qiankun/slave/slaveRuntimePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { createHistory } from '@@/core/history';
import qiankunRender, { contextOptsStack } from './lifecycles';

export function render(oldRender: any) {
// 在 ssr 的场景下,直接返回旧的 render
if (typeof window === 'undefined') {
return oldRender();
}
return qiankunRender().then(oldRender);
}

Expand Down
1 change: 0 additions & 1 deletion packages/plugins/src/qiankun/master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ export { MicroAppWithMemoHistory } from './MicroAppWithMemoHistory';
...originalExternals,
qiankun: 'fs',
});
return config;
}

return config;
Expand Down

0 comments on commit 4b375ca

Please sign in to comment.