File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
packages/react-devtools-shared/src Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import {
3434 shallowDiffers ,
3535 utfDecodeStringWithRanges ,
3636 parseElementDisplayNameFromBackend ,
37+ unionOfTwoArrays ,
3738} from '../utils' ;
3839import { localStorageGetItem , localStorageSetItem } from '../storage' ;
3940import { __DEBUG__ } from '../constants' ;
@@ -956,9 +957,17 @@ export default class Store extends EventEmitter<{
956957 child . rects !== null &&
957958 child . rects . length > 0 &&
958959 child . rects . some ( isNonZeroRect ) ;
959- const environments = child . environments ;
960+ const childEnvironments = child . environments ;
961+ // Since children are blocked on the parent, they're also blocked by the parent environments.
962+ // Only if we discover a novel environment do we add that and it becomes the name we use.
963+ const unionEnvironments = unionOfTwoArrays (
964+ parentEnvironments ,
965+ childEnvironments ,
966+ ) ;
960967 const environmentName =
961- environments . length > 0 ? environments [ environments . length - 1 ] : null ;
968+ unionEnvironments . length > 0
969+ ? unionEnvironments [ unionEnvironments . length - 1 ]
970+ : null ;
962971 if ( hasRects && ( ! uniqueSuspendersOnly || child . hasUniqueSuspenders ) ) {
963972 target . push ( {
964973 id : child . id ,
@@ -969,7 +978,7 @@ export default class Store extends EventEmitter<{
969978 child . children ,
970979 target ,
971980 uniqueSuspendersOnly ,
972- environments ,
981+ unionEnvironments ,
973982 ) ;
974983 }
975984 }
Original file line number Diff line number Diff line change @@ -1305,3 +1305,18 @@ export function onReloadAndProfileFlagsReset(): void {
13051305 sessionStorageRemoveItem ( SESSION_STORAGE_RECORD_CHANGE_DESCRIPTIONS_KEY ) ;
13061306 sessionStorageRemoveItem ( SESSION_STORAGE_RECORD_TIMELINE_KEY ) ;
13071307}
1308+
1309+ export function unionOfTwoArrays< T > (a: Array< T > , b: Array< T > ): Array< T > {
1310+ let result = a ;
1311+ for ( let i = 0 ; i < b . length ; i ++ ) {
1312+ const value = b [ i ] ;
1313+ if ( a . indexOf ( value ) === - 1 ) {
1314+ if ( result === a ) {
1315+ // Lazily copy
1316+ result = a . slice ( 0 ) ;
1317+ }
1318+ result . push ( value ) ;
1319+ }
1320+ }
1321+ return result ;
1322+ }
You can’t perform that action at this time.
0 commit comments