@@ -257,8 +257,10 @@ type SuspenseBoundary = {
257257fallbackState : HoistableState ,
258258contentPreamble : null | Preamble ,
259259fallbackPreamble : null | Preamble ,
260- trackedContentKeyPath : null | KeyNode , // used to track the path for replay nodes
261- trackedFallbackNode : null | ReplayNode , // used to track the fallback for replay nodes
260+ tracked : null | {
261+ contentKeyPath : null | KeyNode , // used to track the path for replay nodes
262+ fallbackNode : null | ReplayNode , // used to track the fallback for replay nodes
263+ } ,
262264errorDigest : ?string , // the error hash if it errors
263265// DEV-only fields
264266errorMessage ?: null | string , // the error string if it errors
@@ -803,8 +805,7 @@ function createSuspenseBoundary(
803805fallbackState : createHoistableState ( ) ,
804806 contentPreamble,
805807 fallbackPreamble,
806- trackedContentKeyPath : null ,
807- trackedFallbackNode : null ,
808+ tracked : null ,
808809} ;
809810if ( __DEV__ ) {
810811// DEV-only fields for hidden class
@@ -1303,9 +1304,6 @@ function renderSuspenseBoundary(
13031304defer ,
13041305) ;
13051306}
1306- if ( request . trackedPostpones !== null ) {
1307- newBoundary . trackedContentKeyPath = keyPath ;
1308- }
13091307
13101308const insertionIndex = parentSegment . chunks . length ;
13111309// The children of the boundary segment is actually the fallback.
@@ -1358,9 +1356,12 @@ function renderSuspenseBoundary(
13581356null ,
13591357] ;
13601358trackedPostpones . workingMap . set ( fallbackKeyPath , fallbackReplayNode ) ;
1361- // We are rendering the fallback before the boundary content so we keep track of
1362- // the fallback replay node until we determine if the primary content suspends
1363- newBoundary . trackedFallbackNode = fallbackReplayNode ;
1359+ newBoundary . tracked = {
1360+ contentKeyPath : keyPath ,
1361+ // We are rendering the fallback before the boundary content so we keep track of
1362+ // the fallback replay node until we determine if the primary content suspends
1363+ fallbackNode : fallbackReplayNode ,
1364+ } ;
13641365}
13651366
13661367task . blockedSegment = boundarySegment ;
@@ -3793,14 +3794,21 @@ function trackPostponedBoundary(
37933794// it before flushing and we know that we can't inline it.
37943795boundary . rootSegmentID = request . nextSegmentId ++ ;
37953796
3796- const boundaryKeyPath = boundary . trackedContentKeyPath ;
3797+ const tracked = boundary . tracked ;
3798+ if ( tracked === null ) {
3799+ throw new Error (
3800+ 'It should not be possible to postpone at the root. This is a bug in React.' ,
3801+ ) ;
3802+ }
3803+
3804+ const boundaryKeyPath = tracked . contentKeyPath ;
37973805if ( boundaryKeyPath === null ) {
37983806throw new Error (
37993807'It should not be possible to postpone at the root. This is a bug in React.' ,
38003808) ;
38013809}
38023810
3803- const fallbackReplayNode = boundary . trackedFallbackNode ;
3811+ const fallbackReplayNode = tracked . fallbackNode ;
38043812
38053813const children : Array < ReplayNode > = [];
38063814 const boundaryNode: void | ReplayNode =
@@ -3853,7 +3861,11 @@ function trackPostpone(
38533861trackedPostpones ,
38543862boundary ,
38553863) ;
3856- if ( boundary . trackedContentKeyPath === keyPath && task . childIndex === - 1 ) {
3864+ if (
3865+ boundary . tracked !== null &&
3866+ boundary . tracked . contentKeyPath === keyPath &&
3867+ task . childIndex === - 1
3868+ ) {
38573869// Assign ID
38583870if ( segment . id === - 1 ) {
38593871if ( segment . parentFlushed ) {
@@ -3950,7 +3962,11 @@ function untrackBoundary(request: Request, boundary: SuspenseBoundary) {
39503962if ( trackedPostpones === null ) {
39513963 return;
39523964}
3953- const boundaryKeyPath = boundary . trackedContentKeyPath ;
3965+ const tracked = boundary . tracked ;
3966+ if ( tracked === null ) {
3967+ return;
3968+ }
3969+ const boundaryKeyPath = tracked . contentKeyPath ;
39543970if ( boundaryKeyPath === null ) {
39553971 return;
39563972}
0 commit comments