@@ -61,6 +61,7 @@ import {
6161 Update ,
6262 Ref ,
6363 Deletion ,
64+ ChildDeletion ,
6465 ForceUpdateForLegacySuspense ,
6566} from './ReactFiberFlags' ;
6667import ReactSharedInternals from 'shared/ReactSharedInternals' ;
@@ -2007,6 +2008,14 @@ function updateSuspensePrimaryChildren(
20072008 currentFallbackChildFragment . nextEffect = null ;
20082009 currentFallbackChildFragment . flags = Deletion ;
20092010 workInProgress . firstEffect = workInProgress . lastEffect = currentFallbackChildFragment ;
2011+ let deletions = workInProgress . deletions ;
2012+ if ( deletions === null ) {
2013+ deletions = workInProgress . deletions = [ currentFallbackChildFragment ] ;
2014+ workInProgress . flags |= ChildDeletion ;
2015+ } else {
2016+ deletions . push ( currentFallbackChildFragment ) ;
2017+ }
2018+ currentFallbackChildFragment . deletions = deletions ;
20102019 }
20112020
20122021 workInProgress . child = primaryChildFragment ;
@@ -2061,21 +2070,23 @@ function updateSuspenseFallbackChildren(
20612070 currentPrimaryChildFragment . treeBaseDuration ;
20622071 }
20632072
2064- // The fallback fiber was added as a deletion effect during the first pass.
2065- // However, since we're going to remain on the fallback, we no longer want
2066- // to delete it. So we need to remove it from the list. Deletions are stored
2067- // on the same list as effects. We want to keep the effects from the primary
2068- // tree. So we copy the primary child fragment's effect list, which does not
2069- // include the fallback deletion effect.
2070- const progressedLastEffect = primaryChildFragment . lastEffect ;
2071- if ( progressedLastEffect !== null ) {
2072- workInProgress . firstEffect = primaryChildFragment . firstEffect ;
2073- workInProgress . lastEffect = progressedLastEffect ;
2074- progressedLastEffect . nextEffect = null ;
2075- } else {
2076- // TODO: Reset this somewhere else? Lol legacy mode is so weird.
2077- workInProgress . firstEffect = workInProgress . lastEffect = null ;
2073+ if ( currentFallbackChildFragment !== null ) {
2074+ // The fallback fiber was added as a deletion effect during the first
2075+ // pass. However, since we're going to remain on the fallback, we no
2076+ // longer want to delete it. So we need to remove it from the list.
2077+ // Deletions are stored on the same list as effects, and are always added
2078+ // to the front. So we know that the first effect must be the fallback
2079+ // deletion effect, and everything after that is from the primary free.
2080+ const firstPrimaryTreeEffect = currentFallbackChildFragment . nextEffect ;
2081+ if ( firstPrimaryTreeEffect !== null ) {
2082+ workInProgress . firstEffect = firstPrimaryTreeEffect ;
2083+ } else {
2084+ // TODO: Reset this somewhere else? Lol legacy mode is so weird.
2085+ workInProgress . firstEffect = workInProgress . lastEffect = null ;
2086+ }
20782087 }
2088+
2089+ workInProgress . deletions = null ;
20792090 } else {
20802091 primaryChildFragment = createWorkInProgressOffscreenFiber (
20812092 currentPrimaryChildFragment ,
@@ -2982,6 +2993,15 @@ function remountFiber(
29822993 current . nextEffect = null ;
29832994 current . flags = Deletion ;
29842995
2996+ let deletions = returnFiber . deletions ;
2997+ if ( deletions === null ) {
2998+ deletions = returnFiber . deletions = [ current ] ;
2999+ returnFiber . flags |= ChildDeletion ;
3000+ } else {
3001+ deletions . push ( current ) ;
3002+ }
3003+ current . deletions = deletions ;
3004+
29853005 newWorkInProgress . flags |= Placement ;
29863006
29873007 // Restart work from the new fiber.
0 commit comments