File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
packages/react-reconciler/src Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -324,16 +324,19 @@ if (__DEV__) {
324324 ReactStrictModeWarnings . flushLegacyContextWarning = ( ) => {
325325 ( ( pendingLegacyContextWarning : any ) : FiberToFiberComponentsMap ) . forEach (
326326 ( fiberArray : FiberArray , strictRoot ) => {
327+ if ( fiberArray . length === 0 ) {
328+ return ;
329+ }
330+ const firstFiber = fiberArray [ 0 ] ;
331+
327332 const uniqueNames = new Set ( ) ;
328333 fiberArray . forEach ( fiber => {
329334 uniqueNames . add ( getComponentName ( fiber . type ) || 'Component' ) ;
330335 didWarnAboutLegacyContext . add ( fiber . type ) ;
331336 } ) ;
332337
333338 const sortedNames = setToSortedString ( uniqueNames ) ;
334- const strictRootComponentStack = getStackByFiberInDevAndProd (
335- strictRoot ,
336- ) ;
339+ const firstComponentStack = getStackByFiberInDevAndProd ( firstFiber ) ;
337340
338341 console . error (
339342 'Legacy context API has been detected within a strict-mode tree.' +
@@ -343,7 +346,7 @@ if (__DEV__) {
343346 '\n\nLearn more about this warning here: https://fb.me/react-legacy-context' +
344347 '%s' ,
345348 sortedNames ,
346- strictRootComponentStack ,
349+ firstComponentStack ,
347350 ) ;
348351 } ,
349352 ) ;
You can’t perform that action at this time.
0 commit comments