@@ -1437,6 +1437,9 @@ export function attach(
14371437 }
14381438
14391439 function recordResetChildren ( fiber : Fiber , childSet : Fiber ) {
1440+ if ( __DEBUG__ ) {
1441+ debug ( 'recordResetChildren()' , childSet , fiber ) ;
1442+ }
14401443 // The frontend only really cares about the displayName, key, and children.
14411444 // The first two don't really change, so we are only concerned with the order of children here.
14421445 // This is trickier than a simple comparison though, since certain types of fibers are filtered.
@@ -1471,6 +1474,23 @@ export function attach(
14711474 nextChildren . push ( getFiberID ( getPrimaryFiber ( fiber ) ) ) ;
14721475 } else {
14731476 let child = fiber . child ;
1477+ const isTimedOutSuspense =
1478+ fiber . tag === SuspenseComponent && fiber . memoizedState !== null ;
1479+ if ( isTimedOutSuspense ) {
1480+ // Special case: if Suspense mounts in a timed-out state,
1481+ // get the fallback child from the inner fragment,
1482+ // and skip over the primary child.
1483+ const primaryChildFragment = fiber . child ;
1484+ const fallbackChildFragment = primaryChildFragment
1485+ ? primaryChildFragment . sibling
1486+ : null ;
1487+ const fallbackChild = fallbackChildFragment
1488+ ? fallbackChildFragment . child
1489+ : null ;
1490+ if ( fallbackChild !== null ) {
1491+ child = fallbackChild ;
1492+ }
1493+ }
14741494 while ( child !== null ) {
14751495 findReorderedChildrenRecursively ( child , nextChildren ) ;
14761496 child = child . sibling ;
@@ -1592,7 +1612,7 @@ export function attach(
15921612 if ( nextFallbackChildSet != null ) {
15931613 mountFiberRecursively (
15941614 nextFallbackChildSet ,
1595- nextFiber ,
1615+ shouldIncludeInTree ? nextFiber : parentFiber ,
15961616 true ,
15971617 traceNearestHostComponentUpdate ,
15981618 ) ;
0 commit comments