-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: refactor-microapp #2853
Conversation
bravepg
commented
Dec 21, 2023
- 补充 react microapp 的 demo
- name & entry 必填
- 前一个子应用出错后,可以加载其他子应用
- 复用 microapp,name 属性变化时,等待前一个子应用卸载完成
🦋 Changeset detectedLatest commit: 0eb3769 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
} | ||
|
||
// 等待 prevMicroApp 卸载完成 | ||
if (prevMicroApp?._unmounting) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果 name 改变,等待前一个卸载完成
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里确定下 同一个组件,不同name渲染的时候,需要等下上一个应用卸载完成再 更改路由吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,不然的话,上一个卸载在调用 unmount 的时候可能会出现找不到 dom 的情况
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
但是跳转 push 是在 主应用操作的, 而卸载的 promise 是在组件里面 await 的 。现在还应该还是先执行 push
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个只是解决以组件模式切换 name 时候的问题。你说的这个其实不需要关注,因为 push 导致的路由变化是异步的浏览器行为,我们不太可能也不应该等组件卸载完了,再让浏览器路由变化,不然一旦 unmount 时间比较久,浏览器感觉像是卡顿了一样。
}, | ||
microApp: microAppRef.current, | ||
componentProps, | ||
setMicroApp: (app) => (microAppRef.current = app), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是 mountMicroApp 方法返回 microApp 实例,然后调用方 setMicroApp,而不应该是 mountMicroApp 里面做这个事情
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯~听上去更舒服,我重写下
}: { | ||
container: HTMLDivElement; | ||
microApp?: MicroAppType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个参数应该叫 prevMicroApp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
合理 我改下
.changeset/gorgeous-geckos-act.md
Outdated
"@qiankunjs/react": patch | ||
"@qiankunjs/ui-shared": patch | ||
"@qiankunjs/vue": patch | ||
"main": patch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"main": patch |
2099225
to
2c8262a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM