Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor-microapp #2853

Merged
merged 5 commits into from
Dec 25, 2023
Merged

feat: refactor-microapp #2853

merged 5 commits into from
Dec 25, 2023

Conversation

bravepg
Copy link
Contributor

@bravepg bravepg commented Dec 21, 2023

  1. 补充 react microapp 的 demo
  2. name & entry 必填
  3. 前一个子应用出错后,可以加载其他子应用
  4. 复用 microapp,name 属性变化时,等待前一个子应用卸载完成

Copy link

changeset-bot bot commented Dec 21, 2023

🦋 Changeset detected

Latest commit: 0eb3769

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@qiankunjs/ui-shared Patch
@qiankunjs/react Patch
@qiankunjs/vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
qiankun ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 24, 2023 10:06am

examples/main/package.json Show resolved Hide resolved
pnpm-workspace.yaml Outdated Show resolved Hide resolved
packages/ui-bindings/shared/src/index.ts Show resolved Hide resolved
}

// 等待 prevMicroApp 卸载完成
if (prevMicroApp?._unmounting) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果 name 改变,等待前一个卸载完成

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里确定下 同一个组件,不同name渲染的时候,需要等下上一个应用卸载完成再 更改路由吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,不然的话,上一个卸载在调用 unmount 的时候可能会出现找不到 dom 的情况

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但是跳转 push 是在 主应用操作的, 而卸载的 promise 是在组件里面 await 的 。现在还应该还是先执行 push

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个只是解决以组件模式切换 name 时候的问题。你说的这个其实不需要关注,因为 push 导致的路由变化是异步的浏览器行为,我们不太可能也不应该等组件卸载完了,再让浏览器路由变化,不然一旦 unmount 时间比较久,浏览器感觉像是卡顿了一样。

@bravepg bravepg requested a review from kuitos December 21, 2023 12:05
},
microApp: microAppRef.current,
componentProps,
setMicroApp: (app) => (microAppRef.current = app),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该是 mountMicroApp 方法返回 microApp 实例,然后调用方 setMicroApp,而不应该是 mountMicroApp 里面做这个事情

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯~听上去更舒服,我重写下

}: {
container: HTMLDivElement;
microApp?: MicroAppType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个参数应该叫 prevMicroApp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

合理 我改下

"@qiankunjs/react": patch
"@qiankunjs/ui-shared": patch
"@qiankunjs/vue": patch
"main": patch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"main": patch

Copy link
Member

@kuitos kuitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kuitos kuitos merged commit 9ec1595 into next Dec 25, 2023
7 checks passed
@kuitos kuitos deleted the feat/refactor-microapp branch December 25, 2023 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants