Skip to content

Commit

Permalink
fix(templateRef): prevent unnecessary set ref during unmounting
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed Jan 3, 2025
1 parent 5a6e98c commit ca052b8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/runtime-core/src/rendererTemplateRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,13 @@ export function setRef(
// #1789: for non-null values, set them after render
// null values means this is unmount and it should not overwrite another
// ref with the same key
;(doSet as SchedulerJob).id = -1
queuePostRenderEffect(doSet, parentSuspense)
const job: SchedulerJob = () => {
if (!(vnode as any).__isUnmounting) doSet()
}
job.id = -1
queuePostRenderEffect(job, parentSuspense)
} else {
;(vnode as any).__isUnmounting = true
doSet()
}
} else if (__DEV__) {
Expand Down

0 comments on commit ca052b8

Please sign in to comment.