@@ -123,7 +123,6 @@ import {
123
123
enableViewTransition ,
124
124
enableFragmentRefs ,
125
125
} from 'shared/ReactFeatureFlags' ;
126
- import isArray from 'shared/isArray' ;
127
126
import shallowEqual from 'shared/shallowEqual' ;
128
127
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber' ;
129
128
import getComponentNameFromType from 'shared/getComponentNameFromType' ;
@@ -132,7 +131,6 @@ import {
132
131
REACT_LAZY_TYPE ,
133
132
REACT_FORWARD_REF_TYPE ,
134
133
REACT_MEMO_TYPE ,
135
- getIteratorFn ,
136
134
} from 'shared/ReactSymbols' ;
137
135
import { setCurrentFiber } from './ReactCurrentFiber' ;
138
136
import {
@@ -145,6 +143,7 @@ import {
145
143
mountChildFibers ,
146
144
reconcileChildFibers ,
147
145
cloneChildFibers ,
146
+ validateSuspenseListChildren ,
148
147
} from './ReactChildFiber' ;
149
148
import {
150
149
processUpdateQueue ,
@@ -3302,73 +3301,6 @@ function validateTailOptions(
3302
3301
}
3303
3302
}
3304
3303
3305
- function validateSuspenseListNestedChild ( childSlot : mixed , index : number ) {
3306
- if ( __DEV__ ) {
3307
- const isAnArray = isArray ( childSlot ) ;
3308
- const isIterable =
3309
- ! isAnArray && typeof getIteratorFn ( childSlot ) === 'function' ;
3310
- if ( isAnArray || isIterable ) {
3311
- const type = isAnArray ? 'array' : 'iterable' ;
3312
- console . error (
3313
- 'A nested %s was passed to row #%s in <SuspenseList />. Wrap it in ' +
3314
- 'an additional SuspenseList to configure its revealOrder: ' +
3315
- '<SuspenseList revealOrder=...> ... ' +
3316
- '<SuspenseList revealOrder=...>{%s}</SuspenseList> ... ' +
3317
- '</SuspenseList>' ,
3318
- type ,
3319
- index ,
3320
- type ,
3321
- ) ;
3322
- return false ;
3323
- }
3324
- }
3325
- return true ;
3326
- }
3327
-
3328
- function validateSuspenseListChildren (
3329
- children : mixed ,
3330
- revealOrder : SuspenseListRevealOrder ,
3331
- ) {
3332
- if ( __DEV__ ) {
3333
- if (
3334
- ( revealOrder === 'forwards' || revealOrder === 'backwards' ) &&
3335
- children !== undefined &&
3336
- children !== null &&
3337
- children !== false
3338
- ) {
3339
- if ( isArray ( children ) ) {
3340
- for ( let i = 0 ; i < children . length ; i ++ ) {
3341
- if ( ! validateSuspenseListNestedChild ( children [ i ] , i ) ) {
3342
- return ;
3343
- }
3344
- }
3345
- } else {
3346
- const iteratorFn = getIteratorFn ( children ) ;
3347
- if ( typeof iteratorFn === 'function' ) {
3348
- const childrenIterator = iteratorFn . call ( children ) ;
3349
- if ( childrenIterator ) {
3350
- let step = childrenIterator . next ( ) ;
3351
- let i = 0 ;
3352
- for ( ; ! step . done ; step = childrenIterator . next ( ) ) {
3353
- if ( ! validateSuspenseListNestedChild ( step . value , i ) ) {
3354
- return ;
3355
- }
3356
- i ++ ;
3357
- }
3358
- }
3359
- } else {
3360
- console . error (
3361
- 'A single row was passed to a <SuspenseList revealOrder="%s" />. ' +
3362
- 'This is not useful since it needs multiple rows. ' +
3363
- 'Did you mean to pass multiple children or an array?' ,
3364
- revealOrder ,
3365
- ) ;
3366
- }
3367
- }
3368
- }
3369
- }
3370
- }
3371
-
3372
3304
function initSuspenseListRenderState (
3373
3305
workInProgress : Fiber ,
3374
3306
isBackwards : boolean ,
@@ -3415,12 +3347,6 @@ function updateSuspenseListComponent(
3415
3347
const tailMode : SuspenseListTailMode = nextProps . tail ;
3416
3348
const newChildren = nextProps . children ;
3417
3349
3418
- validateRevealOrder ( revealOrder ) ;
3419
- validateTailOptions ( tailMode , revealOrder ) ;
3420
- validateSuspenseListChildren ( newChildren , revealOrder ) ;
3421
-
3422
- reconcileChildren ( current , workInProgress , newChildren , renderLanes ) ;
3423
-
3424
3350
let suspenseContext : SuspenseContext = suspenseStackCursor . current ;
3425
3351
3426
3352
const shouldForceFallback = hasSuspenseListContext (
@@ -3434,6 +3360,17 @@ function updateSuspenseListComponent(
3434
3360
) ;
3435
3361
workInProgress . flags |= DidCapture ;
3436
3362
} else {
3363
+ suspenseContext = setDefaultShallowSuspenseListContext ( suspenseContext ) ;
3364
+ }
3365
+ pushSuspenseListContext ( workInProgress , suspenseContext ) ;
3366
+
3367
+ validateRevealOrder ( revealOrder ) ;
3368
+ validateTailOptions ( tailMode , revealOrder ) ;
3369
+ validateSuspenseListChildren ( newChildren , revealOrder ) ;
3370
+
3371
+ reconcileChildren ( current , workInProgress , newChildren , renderLanes ) ;
3372
+
3373
+ if ( ! shouldForceFallback ) {
3437
3374
const didSuspendBefore =
3438
3375
current !== null && ( current . flags & DidCapture ) !== NoFlags ;
3439
3376
if ( didSuspendBefore ) {
@@ -3446,9 +3383,7 @@ function updateSuspenseListComponent(
3446
3383
renderLanes ,
3447
3384
) ;
3448
3385
}
3449
- suspenseContext = setDefaultShallowSuspenseListContext ( suspenseContext ) ;
3450
3386
}
3451
- pushSuspenseListContext ( workInProgress , suspenseContext ) ;
3452
3387
3453
3388
if ( ! disableLegacyMode && ( workInProgress . mode & ConcurrentMode ) === NoMode ) {
3454
3389
// In legacy mode, SuspenseList doesn't work so we just
0 commit comments