File tree 1 file changed +7
-4
lines changed
packages/react-reconciler/src
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -324,16 +324,19 @@ if (__DEV__) {
324
324
ReactStrictModeWarnings . flushLegacyContextWarning = ( ) => {
325
325
( ( pendingLegacyContextWarning : any ) : FiberToFiberComponentsMap ) . forEach (
326
326
( fiberArray : FiberArray , strictRoot ) => {
327
+ if ( fiberArray . length === 0 ) {
328
+ return ;
329
+ }
330
+ const firstFiber = fiberArray [ 0 ] ;
331
+
327
332
const uniqueNames = new Set ( ) ;
328
333
fiberArray . forEach ( fiber => {
329
334
uniqueNames . add ( getComponentName ( fiber . type ) || 'Component' ) ;
330
335
didWarnAboutLegacyContext . add ( fiber . type ) ;
331
336
} ) ;
332
337
333
338
const sortedNames = setToSortedString ( uniqueNames ) ;
334
- const strictRootComponentStack = getStackByFiberInDevAndProd (
335
- strictRoot ,
336
- ) ;
339
+ const firstComponentStack = getStackByFiberInDevAndProd ( firstFiber ) ;
337
340
338
341
console . error (
339
342
'Legacy context API has been detected within a strict-mode tree.' +
@@ -343,7 +346,7 @@ if (__DEV__) {
343
346
'\n\nLearn more about this warning here: https://fb.me/react-legacy-context' +
344
347
'%s' ,
345
348
sortedNames ,
346
- strictRootComponentStack ,
349
+ firstComponentStack ,
347
350
) ;
348
351
} ,
349
352
) ;
You can’t perform that action at this time.
0 commit comments