100
FormReset,
101
} from './ReactFiberFlags';
102
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
103
-import {
104
- resetCurrentDebugFiberInDEV,
105
- setCurrentDebugFiberInDEV,
106
- getCurrentFiber as getCurrentDebugFiberInDEV,
107
-} from './ReactCurrentFiber';
103
+import {runWithFiberInDEV} from './ReactCurrentFiber';
104
import {resolveClassComponentProps} from './ReactFiberClassComponent';
105
import {
106
isCurrentUpdateNested,
399
function commitBeforeMutationEffects_complete() {
400
while (nextEffect !== null) {
401
const fiber = nextEffect;
406
- setCurrentDebugFiberInDEV(fiber);
402
try {
408
- commitBeforeMutationEffectsOnFiber(fiber);
403
+ if (__DEV__) {
404
+ runWithFiberInDEV(fiber, commitBeforeMutationEffectsOnFiber, fiber);
405
+ } else {
406
+ commitBeforeMutationEffectsOnFiber(fiber);
407
+ }
408
} catch (error) {
409
captureCommitPhaseError(fiber, fiber.return, error);
410
}
412
- resetCurrentDebugFiberInDEV();
411
412
const sibling = fiber.sibling;
413
if (sibling !== null) {
440
}
441
}
442
445
- if ((flags & Snapshot) !== NoFlags) {
446
- setCurrentDebugFiberInDEV(finishedWork);
447
- }
448
-
443
switch (finishedWork.tag) {
444
case FunctionComponent: {
445
if (enableUseEffectEventHook) {
541
}
542
}
543
}
550
-
551
- if ((flags & Snapshot) !== NoFlags) {
552
- resetCurrentDebugFiberInDEV();
553
- }
544
}
545
546
function commitBeforeMutationEffectsDeletion(deletion: Fiber) {
2474
inProgressLanes = committedLanes;
2475
inProgressRoot = root;
2476
2487
- setCurrentDebugFiberInDEV(finishedWork);
2488
- commitMutationEffectsOnFiber(finishedWork, root, committedLanes);
2489
- resetCurrentDebugFiberInDEV();
2477
+ if (__DEV__) {
2478
+ runWithFiberInDEV(
2479
+ finishedWork,
2480
+ commitMutationEffectsOnFiber,
2481
+ finishedWork,
2482
+ root,
2483
+ committedLanes,
2484
+ );
2485
+ } else {
2486
+ commitMutationEffectsOnFiber(finishedWork, root, committedLanes);
2487
+ }
2488
2489
inProgressLanes = null;
2490
inProgressRoot = null;
2509
}
2510
}
2511
2514
- const prevDebugFiber = getCurrentDebugFiberInDEV();
2512
if (parentFiber.subtreeFlags & MutationMask) {
2513
let child = parentFiber.child;
2514
while (child !== null) {
2518
- setCurrentDebugFiberInDEV(child);
2519
- commitMutationEffectsOnFiber(child, root, lanes);
2515
+ if (__DEV__) {
2516
+ runWithFiberInDEV(
2517
+ child,
2518
+ commitMutationEffectsOnFiber,
2519
+ child,
2520
+ root,
2521
+ lanes,
2522
+ );
2523
+ } else {
2524
+ commitMutationEffectsOnFiber(child, root, lanes);
2525
+ }
2526
child = child.sibling;
2527
}
2528
}
2523
- setCurrentDebugFiberInDEV(prevDebugFiber);
2529
}
2530
2531
let currentHoistableRoot: HoistableRoot | null = null;
3130
inProgressLanes = committedLanes;
3131
inProgressRoot = root;
3132
3128
- setCurrentDebugFiberInDEV(finishedWork);
3133
const current = finishedWork.alternate;
3130
- commitLayoutEffectOnFiber(root, current, finishedWork, committedLanes);
3131
- resetCurrentDebugFiberInDEV();
3134
+ if (__DEV__) {
3135
+ runWithFiberInDEV(
3136
+ finishedWork,
3137
+ commitLayoutEffectOnFiber,
3138
+ root,
3139
+ current,
3140
+ finishedWork,
3141
+ committedLanes,
3142
+ );
3143
+ } else {
3144
+ commitLayoutEffectOnFiber(root, current, finishedWork, committedLanes);
3145
+ }
3146
3147
inProgressLanes = null;
3148
inProgressRoot = null;
3153
parentFiber: Fiber,
3154
lanes: Lanes,
3155
) {
3142
- const prevDebugFiber = getCurrentDebugFiberInDEV();
3156
if (parentFiber.subtreeFlags & LayoutMask) {
3157
let child = parentFiber.child;
3158
while (child !== null) {
3146
- setCurrentDebugFiberInDEV(child);
3159
const current = child.alternate;
3148
- commitLayoutEffectOnFiber(root, current, child, lanes);
3160
+ if (__DEV__) {
3161
+ runWithFiberInDEV(
3162
+ child,
3163
+ commitLayoutEffectOnFiber,
3164
+ root,
3165
+ current,
3166
+ child,
3167
+ lanes,
3168
+ );
3169
+ } else {
3170
+ commitLayoutEffectOnFiber(root, current, child, lanes);
3171
+ }
3172
child = child.sibling;
3173
}
3174
}
3152
- setCurrentDebugFiberInDEV(prevDebugFiber);
3175
}
3176
3177
export function disappearLayoutEffects(finishedWork: Fiber) {
3408
(parentFiber.subtreeFlags & LayoutMask) !== NoFlags;
3409
3410
// TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic)
3389
- const prevDebugFiber = getCurrentDebugFiberInDEV();
3411
let child = parentFiber.child;
3412
while (child !== null) {
3413
const current = child.alternate;
3393
- reappearLayoutEffects(
3394
- finishedRoot,
3395
- current,
3396
- child,
3397
- childShouldIncludeWorkInProgressEffects,
3398
- );
3414
+ if (__DEV__) {
3415
+ runWithFiberInDEV(
3416
+ child,
3417
+ reappearLayoutEffects,
3418
+ finishedRoot,
3419
+ current,
3420
+ child,
3421
+ childShouldIncludeWorkInProgressEffects,
3422
+ );
3423
+ } else {
3424
+ reappearLayoutEffects(
3425
+ finishedRoot,
3426
+ current,
3427
+ child,
3428
+ childShouldIncludeWorkInProgressEffects,
3429
+ );
3430
+ }
3431
child = child.sibling;
3432
}
3401
- setCurrentDebugFiberInDEV(prevDebugFiber);
3433
}
3434
3435
function commitHookPassiveMountEffects(
3599
committedLanes: Lanes,
3600
committedTransitions: Array<Transition> | null,
3601
): void {
3571
- setCurrentDebugFiberInDEV(finishedWork);
3572
- commitPassiveMountOnFiber(
3573
- root,
3574
- finishedWork,
3575
- committedLanes,
3576
- committedTransitions,
3577
- );
3578
- resetCurrentDebugFiberInDEV();
3602
+ if (__DEV__) {
3603
+ runWithFiberInDEV(
3604
+ finishedWork,
3605
+ commitPassiveMountOnFiber,
3606
+ root,
3607
+ finishedWork,
3608
+ committedLanes,
3609
+ committedTransitions,
3610
+ );
3611
+ } else {
3612
+ commitPassiveMountOnFiber(
3613
+ root,
3614
+ finishedWork,
3615
+ committedLanes,
3616
+ committedTransitions,
3617
+ );
3618
+ }
3619
}
3620
3621
function recursivelyTraversePassiveMountEffects(
3624
committedLanes: Lanes,
3625
committedTransitions: Array<Transition> | null,
3626
) {
3587
- const prevDebugFiber = getCurrentDebugFiberInDEV();
3627
if (parentFiber.subtreeFlags & PassiveMask) {
3628
let child = parentFiber.child;
3629
while (child !== null) {
3591
- setCurrentDebugFiberInDEV(child);
3592
- commitPassiveMountOnFiber(
3593
- root,
3594
- child,
3595
- committedLanes,
3596
- committedTransitions,
3597
- );
3630
+ if (__DEV__) {
3631
+ runWithFiberInDEV(
3632
+ child,
3633
+ commitPassiveMountOnFiber,
3634
+ root,
3635
+ child,
3636
+ committedLanes,
3637
+ committedTransitions,
3638
+ );
3639
+ } else {
3640
+ commitPassiveMountOnFiber(
3641
+ root,
3642
+ child,
3643
+ committedLanes,
3644
+ committedTransitions,
3645
+ );
3646
+ }
3647
child = child.sibling;
3648
}
3649
}
3601
- setCurrentDebugFiberInDEV(prevDebugFiber);
3650
}
3651
3652
function commitPassiveMountOnFiber(
3883
(parentFiber.subtreeFlags & PassiveMask) !== NoFlags;
3884
3885
// TODO (Offscreen) Check: flags & (RefStatic | LayoutStatic)
3838
- const prevDebugFiber = getCurrentDebugFiberInDEV();
3886
let child = parentFiber.child;
3887
while (child !== null) {
3841
- reconnectPassiveEffects(
3842
- finishedRoot,
3843
- child,
3844
- committedLanes,
3845
- committedTransitions,
3846
- childShouldIncludeWorkInProgressEffects,
3847
- );
3888
+ if (__DEV__) {
3889
+ runWithFiberInDEV(
3890
+ child,
3891
+ reconnectPassiveEffects,
3892
+ finishedRoot,
3893
+ child,
3894
+ committedLanes,
3895
+ committedTransitions,
3896
+ childShouldIncludeWorkInProgressEffects,
3897
+ );
3898
+ } else {
3899
+ reconnectPassiveEffects(
3900
+ finishedRoot,
3901
+ child,
3902
+ committedLanes,
3903
+ committedTransitions,
3904
+ childShouldIncludeWorkInProgressEffects,
3905
+ );
3906
+ }
3907
child = child.sibling;
3908
}
3850
- setCurrentDebugFiberInDEV(prevDebugFiber);
3909
}
3910
3911
export function reconnectPassiveEffects(
4081
// "Atomic" effects are ones that need to fire on every commit, even during
4082
// pre-rendering. We call this function when traversing a hidden tree whose
4083
// regular effects are currently disconnected.
4026
- const prevDebugFiber = getCurrentDebugFiberInDEV();
4084
// TODO: Add special flag for atomic effects
4085
if (parentFiber.subtreeFlags & PassiveMask) {
4086
let child = parentFiber.child;
4087
while (child !== null) {
4031
- setCurrentDebugFiberInDEV(child);
4032
- commitAtomicPassiveEffects(
4033
- finishedRoot,
4034
- child,
4035
- committedLanes,
4036
- committedTransitions,
4037
- );
4088
+ if (__DEV__) {
4089
+ runWithFiberInDEV(
4090
+ child,
4091
+ commitAtomicPassiveEffects,
4092
+ finishedRoot,
4093
+ child,
4094
+ committedLanes,
4095
+ committedTransitions,
4096
+ );
4097
+ } else {
4098
+ commitAtomicPassiveEffects(
4099
+ finishedRoot,
4100
+ child,
4101
+ committedLanes,
4102
+ committedTransitions,
4103
+ );
4104
+ }
4105
child = child.sibling;
4106
}
4107
}
4041
- setCurrentDebugFiberInDEV(prevDebugFiber);
4108
}
4109
4110
function commitAtomicPassiveEffects(
4160
}
4161
4162
export function commitPassiveUnmountEffects(finishedWork: Fiber): void {
4097
- setCurrentDebugFiberInDEV(finishedWork);
4098
- commitPassiveUnmountOnFiber(finishedWork);
4099
- resetCurrentDebugFiberInDEV();
4163
+ if (__DEV__) {
4164
+ runWithFiberInDEV(finishedWork, commitPassiveUnmountOnFiber, finishedWork);
4165
+ } else {
4166
+ commitPassiveUnmountOnFiber(finishedWork);
4167
+ }
4168
}
4169
4170
// If we're inside a brand new tree, or a tree that was already visible, then we
4333
detachAlternateSiblings(parentFiber);
4334
}
4335
4268
- const prevDebugFiber = getCurrentDebugFiberInDEV();
4336
// TODO: Split PassiveMask into separate masks for mount and unmount?
4337
if (parentFiber.subtreeFlags & PassiveMask) {
4338
let child = parentFiber.child;
4339
while (child !== null) {
4273
- setCurrentDebugFiberInDEV(child);
4274
- commitPassiveUnmountOnFiber(child);
4340
+ if (__DEV__) {
4341
+ runWithFiberInDEV(child, commitPassiveUnmountOnFiber, child);
4342
+ } else {
4343
+ commitPassiveUnmountOnFiber(child);
4344
+ }
4345
child = child.sibling;
4346
}
4347
}
4278
- setCurrentDebugFiberInDEV(prevDebugFiber);
4348
}
4349
4350
function commitPassiveUnmountOnFiber(finishedWork: Fiber): void {
4415
detachAlternateSiblings(parentFiber);
4416
}
4417
4349
- const prevDebugFiber = getCurrentDebugFiberInDEV();
4418
// TODO: Check PassiveStatic flag
4419
let child = parentFiber.child;
4420
while (child !== null) {
4353
- setCurrentDebugFiberInDEV(child);
4354
- disconnectPassiveEffect(child);
4421
+ if (__DEV__) {
4422
+ runWithFiberInDEV(child, disconnectPassiveEffect, child);
4423
+ } else {
4424
+ disconnectPassiveEffect(child);
4425
+ }
4426
child = child.sibling;
4427
}
4357
- setCurrentDebugFiberInDEV(prevDebugFiber);
4428
}
4429
4430
export function disconnectPassiveEffect(finishedWork: Fiber): void {
4469
4470
// Deletion effects fire in parent -> child order
4471
// TODO: Check if fiber has a PassiveStatic flag
4402
- setCurrentDebugFiberInDEV(fiber);
4403
- commitPassiveUnmountInsideDeletedTreeOnFiber(fiber, nearestMountedAncestor);
4404
- resetCurrentDebugFiberInDEV();
4472
+ if (__DEV__) {
4473
+ runWithFiberInDEV(
4474
+ fiber,
4475
+ commitPassiveUnmountInsideDeletedTreeOnFiber,
4476
+ fiber,
4477
+ nearestMountedAncestor,
4478
+ );
4479
+ } else {
4480
+ commitPassiveUnmountInsideDeletedTreeOnFiber(
4481
+ fiber,
4482
+ nearestMountedAncestor,
4483
+ );
4484
+ }
4485
4486
const child = fiber.child;
4487
// TODO: Only traverse subtree if it has a PassiveStatic flag.