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

fix: 修复 pageId 装载和卸载逻辑不一致的问题 #14179

Merged
merged 6 commits into from
Jul 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/taro-runtime/src/dsl/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ export function createComponentConfig (component: React.ComponentClass, componen
const config: any = {
[ATTACHED] () {
perf.start(PAGE_INIT)
const path = getPath(id, { id: this.getPageId?.() || pageId() })
xuanzebin marked this conversation as resolved.
Show resolved Hide resolved
this.pageIdCache = this.getPageId?.() || pageId()

const path = getPath(id, { id: this.pageIdCache })

Current.app!.mount!(component, path, () => {
componentElement = env.document.getElementById<TaroRootElement>(path)
ensure(componentElement !== null, '没有找到组件实例。')
Expand All @@ -298,7 +301,8 @@ export function createComponentConfig (component: React.ComponentClass, componen
})
},
[DETACHED] () {
const path = getPath(id, { id: this.getPageId() })
const path = getPath(id, { id: this.pageIdCache })

Current.app!.unmount!(path, () => {
instances.delete(path)
if (componentElement) {
Expand Down