@@ -61,6 +61,7 @@ import {
61
61
Update ,
62
62
Ref ,
63
63
Deletion ,
64
+ ChildDeletion ,
64
65
ForceUpdateForLegacySuspense ,
65
66
} from './ReactFiberFlags' ;
66
67
import ReactSharedInternals from 'shared/ReactSharedInternals' ;
@@ -2007,6 +2008,14 @@ function updateSuspensePrimaryChildren(
2007
2008
currentFallbackChildFragment . nextEffect = null ;
2008
2009
currentFallbackChildFragment . flags = Deletion ;
2009
2010
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 ;
2010
2019
}
2011
2020
2012
2021
workInProgress . child = primaryChildFragment ;
@@ -2061,21 +2070,23 @@ function updateSuspenseFallbackChildren(
2061
2070
currentPrimaryChildFragment . treeBaseDuration ;
2062
2071
}
2063
2072
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
+ }
2078
2087
}
2088
+
2089
+ workInProgress . deletions = null ;
2079
2090
} else {
2080
2091
primaryChildFragment = createWorkInProgressOffscreenFiber (
2081
2092
currentPrimaryChildFragment ,
@@ -2982,6 +2993,15 @@ function remountFiber(
2982
2993
current . nextEffect = null ;
2983
2994
current . flags = Deletion ;
2984
2995
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
+
2985
3005
newWorkInProgress . flags |= Placement ;
2986
3006
2987
3007
// Restart work from the new fiber.
0 commit comments