Skip to content

Commit

Permalink
fix: ensure that the container exists before each load
Browse files Browse the repository at this point in the history
  • Loading branch information
bravepg committed Oct 23, 2023
1 parent ea40d92 commit 915901f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/qiankun/src/core/loadApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ export default async function loadApp<T extends ObjectType>(
}
}
},
// 添加 mount hook, 确保每次应用加载前容器存在
async () => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (microAppContainer === null) {
microAppContainer = container;
}
},
async () => {
// if micro app container has no children that means now is remounting, we need to rerender the app manually
if (microAppContainer.firstChild === null) {
Expand Down Expand Up @@ -127,6 +134,10 @@ export default async function loadApp<T extends ObjectType>(
async () => execHooksChain(toArray(afterUnmount), app, global),
async () => {
clearContainer(microAppContainer);
// for gc
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
microAppContainer = null;
},
],
};
Expand Down

0 comments on commit 915901f

Please sign in to comment.