Skip to content

Commit f435e19

Browse files
committed
fix(Suspense): avoid unmount activeBranch twice if wrapped in transtion
1 parent 4711158 commit f435e19

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/runtime-core/src/components/Suspense.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ export interface SuspenseBoundary {
379379
container: RendererElement
380380
hiddenContainer: RendererElement
381381
anchor: RendererNode | null
382-
activeBranch: VNode | null
382+
activeBranch: (VNode & { __isUnmounted?: boolean }) | null
383383
pendingBranch: VNode | null
384384
deps: number
385385
pendingId: number
@@ -508,7 +508,10 @@ function createSuspenseBoundary(
508508
// this is initial anchor on mount
509509
let { anchor } = suspense
510510
// unmount current active tree
511-
if (activeBranch) {
511+
// #7966 if suspense is wrapped in Transition, the Transition's afterLeave may not have been
512+
// performed (this means the fallbackVNode not mounted) when suspense resolves.
513+
// so avoid unmount activeBranch again
514+
if (activeBranch && !activeBranch.__isUnmounted) {
512515
// if the fallback tree was mounted, it may have been moved
513516
// as part of a parent suspense. get the latest anchor for insertion
514517
anchor = next(activeBranch)
@@ -608,6 +611,8 @@ function createSuspenseBoundary(
608611
true // shouldRemove
609612
)
610613

614+
activeBranch!.__isUnmounted = true
615+
611616
if (!delayEnter) {
612617
mountFallback()
613618
}

0 commit comments

Comments
 (0)