File tree 5 files changed +33
-23
lines changed
react-devtools-shared/src/backend
5 files changed +33
-23
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ export function createProfilingHooks({
75
75
reactVersion,
76
76
} : { |
77
77
getDisplayNameForFiber : ( fiber : Fiber ) => string | null ,
78
- getLaneLabelMap ? : ( ) => Map < Lane , string > ,
78
+ getLaneLabelMap ? : ( ) => Map < Lane , string > | null ,
79
79
reactVersion : string ,
80
80
| } ) : DevToolsProfilingHooks {
81
81
function markMetadata ( ) {
@@ -108,8 +108,10 @@ export function createProfilingHooks({
108
108
109
109
if ( typeof getLaneLabelMap === 'function' ) {
110
110
const map = getLaneLabelMap ( ) ;
111
- const labels = Array . from ( map . values ( ) ) . join ( ',' ) ;
112
- markAndClear ( `--react-lane-labels-${ labels } ` ) ;
111
+ if ( map != null ) {
112
+ const labels = Array . from ( map . values ( ) ) . join ( ',' ) ;
113
+ markAndClear ( `--react-lane-labels-${ labels } ` ) ;
114
+ }
113
115
}
114
116
}
115
117
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ export type ReactRenderer = {
152
152
scheduleRefresh ?: Function ,
153
153
// 18.0+
154
154
injectProfilingHooks ?: ( profilingHooks : DevToolsProfilingHooks ) => void ,
155
- getLaneLabelMap ?: ( ) => Map < Lane , string > ,
155
+ getLaneLabelMap ?: ( ) => Map < Lane , string > | null ,
156
156
...
157
157
} ;
158
158
Original file line number Diff line number Diff line change @@ -230,17 +230,21 @@ function injectProfilingHooks(profilingHooks: DevToolsProfilingHooks): void {
230
230
injectedProfilingHooks = profilingHooks ;
231
231
}
232
232
233
- function getLaneLabelMap ( ) : Map < Lane , string > {
234
- const map : Map < Lane , string > = new Map ( ) ;
233
+ function getLaneLabelMap ( ) : Map < Lane , string > | null {
234
+ if ( enableSchedulingProfiler ) {
235
+ const map : Map < Lane , string > = new Map ( ) ;
235
236
236
- let lane = 1 ;
237
- for ( let index = 0 ; index < TotalLanes ; index ++ ) {
238
- const label = ( ( getLabelForLane ( lane ) : any ) : string ) ;
239
- map . set ( lane , label ) ;
240
- lane *= 2 ;
241
- }
237
+ let lane = 1 ;
238
+ for ( let index = 0 ; index < TotalLanes ; index ++ ) {
239
+ const label = ( ( getLabelForLane ( lane ) : any ) : string ) ;
240
+ map . set ( lane , label ) ;
241
+ lane *= 2 ;
242
+ }
242
243
243
- return map ;
244
+ return map ;
245
+ } else {
246
+ return null ;
247
+ }
244
248
}
245
249
246
250
export function markCommitStarted ( lanes : Lanes ) : void {
Original file line number Diff line number Diff line change @@ -230,17 +230,21 @@ function injectProfilingHooks(profilingHooks: DevToolsProfilingHooks): void {
230
230
injectedProfilingHooks = profilingHooks ;
231
231
}
232
232
233
- function getLaneLabelMap ( ) : Map < Lane , string > {
234
- const map : Map < Lane , string > = new Map ( ) ;
233
+ function getLaneLabelMap ( ) : Map < Lane , string > | null {
234
+ if ( enableSchedulingProfiler ) {
235
+ const map : Map < Lane , string > = new Map ( ) ;
235
236
236
- let lane = 1 ;
237
- for ( let index = 0 ; index < TotalLanes ; index ++ ) {
238
- const label = ( ( getLabelForLane ( lane ) : any ) : string ) ;
239
- map . set ( lane , label ) ;
240
- lane *= 2 ;
241
- }
237
+ let lane = 1 ;
238
+ for ( let index = 0 ; index < TotalLanes ; index ++ ) {
239
+ const label = ( ( getLabelForLane ( lane ) : any ) : string ) ;
240
+ map . set ( lane , label ) ;
241
+ lane *= 2 ;
242
+ }
242
243
243
- return map ;
244
+ return map ;
245
+ } else {
246
+ return null ;
247
+ }
244
248
}
245
249
246
250
export function markCommitStarted ( lanes : Lanes ) : void {
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import typeof * as ExportsType from './ReactFeatureFlags.testing';
12
12
13
13
export const debugRenderPhaseSideEffectsForStrictMode = false ;
14
14
export const enableDebugTracing = false ;
15
- export const enableSchedulingProfiler = false ;
15
+ export const enableSchedulingProfiler = __PROFILE__ ;
16
16
export const warnAboutDeprecatedLifecycles = true ;
17
17
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = false ;
18
18
export const enableProfilerTimer = __PROFILE__ ;
You can’t perform that action at this time.
0 commit comments