@@ -40,7 +40,6 @@ import {
40
40
enableSchedulingProfiler ,
41
41
enableSuspenseCallback ,
42
42
enableScopeAPI ,
43
- enableStrictEffects ,
44
43
deletedTreeCleanUpLevel ,
45
44
enableUpdaterTracking ,
46
45
enableCache ,
@@ -195,6 +194,7 @@ let nextEffect: Fiber | null = null;
195
194
// Used for Profiling builds to track updaters.
196
195
let inProgressLanes : Lanes | null = null ;
197
196
let inProgressRoot : FiberRoot | null = null ;
197
+ let enableProfilingDEV = true ;
198
198
199
199
export function reportUncaughtErrorInDEV ( error : mixed ) {
200
200
// Wrapping each small part of the commit phase into a guarded
@@ -216,7 +216,8 @@ const callComponentWillUnmountWithTimer = function(current, instance) {
216
216
if (
217
217
enableProfilerTimer &&
218
218
enableProfilerCommitHooks &&
219
- current . mode & ProfileMode
219
+ current . mode & ProfileMode &&
220
+ enableProfilingDEV
220
221
) {
221
222
try {
222
223
startLayoutEffectTimer ( ) ;
@@ -260,7 +261,8 @@ function safelyDetachRef(current: Fiber, nearestMountedAncestor: Fiber | null) {
260
261
if (
261
262
enableProfilerTimer &&
262
263
enableProfilerCommitHooks &&
263
- current . mode & ProfileMode
264
+ current . mode & ProfileMode &&
265
+ enableProfilingDEV
264
266
) {
265
267
try {
266
268
startLayoutEffectTimer ( ) ;
@@ -637,7 +639,7 @@ export function commitPassiveEffectDurations(
637
639
finishedRoot : FiberRoot ,
638
640
finishedWork : Fiber ,
639
641
) : void {
640
- if ( enableProfilerTimer && enableProfilerCommitHooks ) {
642
+ if ( enableProfilerTimer && enableProfilerCommitHooks && enableProfilingDEV ) {
641
643
// Only Profilers with work in their subtree will have an Update effect scheduled.
642
644
if ( ( finishedWork . flags & Update ) !== NoFlags ) {
643
645
switch ( finishedWork . tag ) {
@@ -693,7 +695,8 @@ function commitHookLayoutEffects(finishedWork: Fiber, hookFlags: HookFlags) {
693
695
if (
694
696
enableProfilerTimer &&
695
697
enableProfilerCommitHooks &&
696
- finishedWork . mode & ProfileMode
698
+ finishedWork . mode & ProfileMode &&
699
+ enableProfilingDEV
697
700
) {
698
701
try {
699
702
startLayoutEffectTimer ( ) ;
@@ -750,7 +753,8 @@ function commitClassLayoutLifecycles(
750
753
if (
751
754
enableProfilerTimer &&
752
755
enableProfilerCommitHooks &&
753
- finishedWork . mode & ProfileMode
756
+ finishedWork . mode & ProfileMode &&
757
+ enableProfilingDEV
754
758
) {
755
759
try {
756
760
startLayoutEffectTimer ( ) ;
@@ -805,7 +809,8 @@ function commitClassLayoutLifecycles(
805
809
if (
806
810
enableProfilerTimer &&
807
811
enableProfilerCommitHooks &&
808
- finishedWork . mode & ProfileMode
812
+ finishedWork . mode & ProfileMode &&
813
+ enableProfilingDEV
809
814
) {
810
815
try {
811
816
startLayoutEffectTimer ( ) ;
@@ -888,7 +893,7 @@ function commitHostComponentMount(finishedWork: Fiber) {
888
893
}
889
894
890
895
function commitProfilerUpdate ( finishedWork : Fiber , current : Fiber | null ) {
891
- if ( enableProfilerTimer ) {
896
+ if ( enableProfilerTimer && enableProfilingDEV ) {
892
897
try {
893
898
const { onCommit, onRender} = finishedWork . memoizedProps ;
894
899
const { effectDuration} = finishedWork . stateNode ;
@@ -1335,7 +1340,8 @@ function commitAttachRef(finishedWork: Fiber) {
1335
1340
if (
1336
1341
enableProfilerTimer &&
1337
1342
enableProfilerCommitHooks &&
1338
- finishedWork . mode & ProfileMode
1343
+ finishedWork . mode & ProfileMode &&
1344
+ enableProfilingDEV
1339
1345
) {
1340
1346
try {
1341
1347
startLayoutEffectTimer ( ) ;
@@ -1378,7 +1384,8 @@ function commitDetachRef(current: Fiber) {
1378
1384
if (
1379
1385
enableProfilerTimer &&
1380
1386
enableProfilerCommitHooks &&
1381
- current . mode & ProfileMode
1387
+ current . mode & ProfileMode &&
1388
+ enableProfilingDEV
1382
1389
) {
1383
1390
try {
1384
1391
startLayoutEffectTimer ( ) ;
@@ -1908,7 +1915,8 @@ function commitDeletionEffectsOnFiber(
1908
1915
if (
1909
1916
enableProfilerTimer &&
1910
1917
enableProfilerCommitHooks &&
1911
- deletedFiber . mode & ProfileMode
1918
+ deletedFiber . mode & ProfileMode &&
1919
+ enableProfilingDEV
1912
1920
) {
1913
1921
startLayoutEffectTimer ( ) ;
1914
1922
safelyCallDestroy (
@@ -2231,7 +2239,8 @@ function commitMutationEffectsOnFiber(
2231
2239
if (
2232
2240
enableProfilerTimer &&
2233
2241
enableProfilerCommitHooks &&
2234
- finishedWork . mode & ProfileMode
2242
+ finishedWork . mode & ProfileMode &&
2243
+ enableProfilingDEV
2235
2244
) {
2236
2245
try {
2237
2246
startLayoutEffectTimer ( ) ;
@@ -2618,7 +2627,7 @@ function recursivelyTraverseLayoutEffects(
2618
2627
setCurrentDebugFiberInDEV ( prevDebugFiber ) ;
2619
2628
}
2620
2629
2621
- function disappearLayoutEffects ( finishedWork : Fiber ) {
2630
+ export function disappearLayoutEffects ( finishedWork : Fiber ) {
2622
2631
switch ( finishedWork . tag ) {
2623
2632
case FunctionComponent :
2624
2633
case ForwardRef :
@@ -2628,7 +2637,8 @@ function disappearLayoutEffects(finishedWork: Fiber) {
2628
2637
if (
2629
2638
enableProfilerTimer &&
2630
2639
enableProfilerCommitHooks &&
2631
- finishedWork . mode & ProfileMode
2640
+ finishedWork . mode & ProfileMode &&
2641
+ enableProfilingDEV
2632
2642
) {
2633
2643
try {
2634
2644
startLayoutEffectTimer ( ) ;
@@ -2700,7 +2710,7 @@ function recursivelyTraverseDisappearLayoutEffects(parentFiber: Fiber) {
2700
2710
}
2701
2711
}
2702
2712
2703
- function reappearLayoutEffects (
2713
+ export function reappearLayoutEffects (
2704
2714
finishedRoot : FiberRoot ,
2705
2715
current : Fiber | null ,
2706
2716
finishedWork : Fiber ,
@@ -2880,7 +2890,8 @@ function commitHookPassiveMountEffects(
2880
2890
if (
2881
2891
enableProfilerTimer &&
2882
2892
enableProfilerCommitHooks &&
2883
- finishedWork . mode & ProfileMode
2893
+ finishedWork . mode & ProfileMode &&
2894
+ enableProfilingDEV
2884
2895
) {
2885
2896
startPassiveEffectTimer ( ) ;
2886
2897
try {
@@ -3305,7 +3316,7 @@ function recursivelyTraverseReconnectPassiveEffects(
3305
3316
setCurrentDebugFiberInDEV ( prevDebugFiber ) ;
3306
3317
}
3307
3318
3308
- function reconnectPassiveEffects (
3319
+ export function reconnectPassiveEffects (
3309
3320
finishedRoot : FiberRoot ,
3310
3321
finishedWork : Fiber ,
3311
3322
committedLanes : Lanes ,
@@ -3589,7 +3600,8 @@ function commitHookPassiveUnmountEffects(
3589
3600
if (
3590
3601
enableProfilerTimer &&
3591
3602
enableProfilerCommitHooks &&
3592
- finishedWork . mode & ProfileMode
3603
+ finishedWork . mode & ProfileMode &&
3604
+ enableProfilingDEV
3593
3605
) {
3594
3606
startPassiveEffectTimer ( ) ;
3595
3607
commitHookEffectListUnmount (
@@ -3719,7 +3731,7 @@ function recursivelyTraverseDisconnectPassiveEffects(parentFiber: Fiber): void {
3719
3731
setCurrentDebugFiberInDEV ( prevDebugFiber ) ;
3720
3732
}
3721
3733
3722
- function disconnectPassiveEffect ( finishedWork : Fiber ) : void {
3734
+ export function disconnectPassiveEffect ( finishedWork : Fiber ) : void {
3723
3735
switch ( finishedWork . tag ) {
3724
3736
case FunctionComponent:
3725
3737
case ForwardRef:
@@ -3871,112 +3883,10 @@ function commitPassiveUnmountInsideDeletedTreeOnFiber(
3871
3883
}
3872
3884
}
3873
3885
3874
- // TODO: Reuse reappearLayoutEffects traversal here?
3875
- function invokeLayoutEffectMountInDEV ( fiber : Fiber ) : void {
3876
- if ( __DEV__ && enableStrictEffects ) {
3877
- // We don't need to re-check StrictEffectsMode here.
3878
- // This function is only called if that check has already passed.
3879
- switch ( fiber . tag ) {
3880
- case FunctionComponent :
3881
- case ForwardRef :
3882
- case SimpleMemoComponent : {
3883
- try {
3884
- commitHookEffectListMount ( HookLayout | HookHasEffect , fiber ) ;
3885
- } catch ( error ) {
3886
- captureCommitPhaseError ( fiber , fiber . return , error ) ;
3887
- }
3888
- break ;
3889
- }
3890
- case ClassComponent : {
3891
- const instance = fiber . stateNode ;
3892
- try {
3893
- instance . componentDidMount ( ) ;
3894
- } catch ( error ) {
3895
- captureCommitPhaseError ( fiber , fiber . return , error ) ;
3896
- }
3897
- break ;
3898
- }
3899
- }
3900
- }
3901
- }
3902
-
3903
- function invokePassiveEffectMountInDEV ( fiber : Fiber ) : void {
3904
- if ( __DEV__ && enableStrictEffects ) {
3905
- // We don't need to re-check StrictEffectsMode here.
3906
- // This function is only called if that check has already passed.
3907
- switch ( fiber . tag ) {
3908
- case FunctionComponent :
3909
- case ForwardRef :
3910
- case SimpleMemoComponent : {
3911
- try {
3912
- commitHookEffectListMount ( HookPassive | HookHasEffect , fiber ) ;
3913
- } catch ( error ) {
3914
- captureCommitPhaseError ( fiber , fiber . return , error ) ;
3915
- }
3916
- break ;
3917
- }
3918
- }
3919
- }
3920
- }
3921
-
3922
- function invokeLayoutEffectUnmountInDEV ( fiber : Fiber ) : void {
3923
- if ( __DEV__ && enableStrictEffects ) {
3924
- // We don't need to re-check StrictEffectsMode here.
3925
- // This function is only called if that check has already passed.
3926
- switch ( fiber . tag ) {
3927
- case FunctionComponent :
3928
- case ForwardRef :
3929
- case SimpleMemoComponent : {
3930
- try {
3931
- commitHookEffectListUnmount (
3932
- HookLayout | HookHasEffect ,
3933
- fiber ,
3934
- fiber . return ,
3935
- ) ;
3936
- } catch ( error ) {
3937
- captureCommitPhaseError ( fiber , fiber . return , error ) ;
3938
- }
3939
- break ;
3940
- }
3941
- case ClassComponent : {
3942
- const instance = fiber . stateNode ;
3943
- if ( typeof instance . componentWillUnmount === 'function' ) {
3944
- safelyCallComponentWillUnmount ( fiber , fiber . return , instance ) ;
3945
- }
3946
- break ;
3947
- }
3948
- }
3949
- }
3950
- }
3951
-
3952
- function invokePassiveEffectUnmountInDEV ( fiber : Fiber ) : void {
3953
- if ( __DEV__ && enableStrictEffects ) {
3954
- // We don't need to re-check StrictEffectsMode here.
3955
- // This function is only called if that check has already passed.
3956
- switch ( fiber . tag ) {
3957
- case FunctionComponent :
3958
- case ForwardRef :
3959
- case SimpleMemoComponent : {
3960
- try {
3961
- commitHookEffectListUnmount (
3962
- HookPassive | HookHasEffect ,
3963
- fiber ,
3964
- fiber . return ,
3965
- ) ;
3966
- } catch ( error ) {
3967
- captureCommitPhaseError ( fiber , fiber . return , error ) ;
3968
- }
3969
- }
3970
- }
3886
+ export function setEnableProfilingDEV ( _enableProfilingDEV : boolean ) {
3887
+ if ( __DEV__ ) {
3888
+ enableProfilingDEV = _enableProfilingDEV ;
3971
3889
}
3972
3890
}
3973
3891
3974
- export {
3975
- commitPlacement ,
3976
- commitAttachRef ,
3977
- commitDetachRef ,
3978
- invokeLayoutEffectMountInDEV ,
3979
- invokeLayoutEffectUnmountInDEV ,
3980
- invokePassiveEffectMountInDEV ,
3981
- invokePassiveEffectUnmountInDEV ,
3982
- } ;
3892
+ export { commitPlacement , commitAttachRef , commitDetachRef } ;
0 commit comments