Skip to content

Commit 595a1cf

Browse files
committed
Remove ReactFiberFlags MountLayoutDev and MountPassiveDev
1 parent 4a257a3 commit 595a1cf

File tree

5 files changed

+59
-241
lines changed

5 files changed

+59
-241
lines changed

packages/react-reconciler/src/ReactFiberClassComponent.new.js

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,13 @@ import type {UpdateQueue} from './ReactFiberClassUpdateQueue.new';
1313
import type {Flags} from './ReactFiberFlags';
1414

1515
import * as React from 'react';
16-
import {
17-
LayoutStatic,
18-
MountLayoutDev,
19-
Update,
20-
Snapshot,
21-
} from './ReactFiberFlags';
16+
import {LayoutStatic, Update, Snapshot} from './ReactFiberFlags';
2217
import {
2318
debugRenderPhaseSideEffectsForStrictMode,
2419
disableLegacyContext,
2520
enableDebugTracing,
2621
enableSchedulingProfiler,
2722
warnAboutDeprecatedLifecycles,
28-
enableStrictEffects,
2923
enableLazyContextPropagation,
3024
} from 'shared/ReactFeatureFlags';
3125
import ReactStrictModeWarnings from './ReactStrictModeWarnings.new';
@@ -39,12 +33,7 @@ import isArray from 'shared/isArray';
3933
import {REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE} from 'shared/ReactSymbols';
4034

4135
import {resolveDefaultProps} from './ReactFiberLazyComponent.new';
42-
import {
43-
DebugTracingMode,
44-
NoMode,
45-
StrictLegacyMode,
46-
StrictEffectsMode,
47-
} from './ReactTypeOfMode';
36+
import {DebugTracingMode, StrictLegacyMode} from './ReactTypeOfMode';
4837

4938
import {
5039
enqueueUpdate,
@@ -907,14 +896,7 @@ function mountClassInstance(
907896
}
908897

909898
if (typeof instance.componentDidMount === 'function') {
910-
let fiberFlags: Flags = Update | LayoutStatic;
911-
if (
912-
__DEV__ &&
913-
enableStrictEffects &&
914-
(workInProgress.mode & StrictEffectsMode) !== NoMode
915-
) {
916-
fiberFlags |= MountLayoutDev;
917-
}
899+
const fiberFlags: Flags = Update | LayoutStatic;
918900
workInProgress.flags |= fiberFlags;
919901
}
920902
}
@@ -985,14 +967,7 @@ function resumeMountClassInstance(
985967
// If an update was already in progress, we should schedule an Update
986968
// effect even though we're bailing out, so that cWU/cDU are called.
987969
if (typeof instance.componentDidMount === 'function') {
988-
let fiberFlags: Flags = Update | LayoutStatic;
989-
if (
990-
__DEV__ &&
991-
enableStrictEffects &&
992-
(workInProgress.mode & StrictEffectsMode) !== NoMode
993-
) {
994-
fiberFlags |= MountLayoutDev;
995-
}
970+
const fiberFlags: Flags = Update | LayoutStatic;
996971
workInProgress.flags |= fiberFlags;
997972
}
998973
return false;
@@ -1036,28 +1011,14 @@ function resumeMountClassInstance(
10361011
}
10371012
}
10381013
if (typeof instance.componentDidMount === 'function') {
1039-
let fiberFlags: Flags = Update | LayoutStatic;
1040-
if (
1041-
__DEV__ &&
1042-
enableStrictEffects &&
1043-
(workInProgress.mode & StrictEffectsMode) !== NoMode
1044-
) {
1045-
fiberFlags |= MountLayoutDev;
1046-
}
1014+
const fiberFlags: Flags = Update | LayoutStatic;
10471015
workInProgress.flags |= fiberFlags;
10481016
}
10491017
} else {
10501018
// If an update was already in progress, we should schedule an Update
10511019
// effect even though we're bailing out, so that cWU/cDU are called.
10521020
if (typeof instance.componentDidMount === 'function') {
1053-
let fiberFlags: Flags = Update | LayoutStatic;
1054-
if (
1055-
__DEV__ &&
1056-
enableStrictEffects &&
1057-
(workInProgress.mode & StrictEffectsMode) !== NoMode
1058-
) {
1059-
fiberFlags |= MountLayoutDev;
1060-
}
1021+
const fiberFlags: Flags = Update | LayoutStatic;
10611022
workInProgress.flags |= fiberFlags;
10621023
}
10631024

packages/react-reconciler/src/ReactFiberClassComponent.old.js

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,13 @@ import type {UpdateQueue} from './ReactFiberClassUpdateQueue.old';
1313
import type {Flags} from './ReactFiberFlags';
1414

1515
import * as React from 'react';
16-
import {
17-
LayoutStatic,
18-
MountLayoutDev,
19-
Update,
20-
Snapshot,
21-
} from './ReactFiberFlags';
16+
import {LayoutStatic, Update, Snapshot} from './ReactFiberFlags';
2217
import {
2318
debugRenderPhaseSideEffectsForStrictMode,
2419
disableLegacyContext,
2520
enableDebugTracing,
2621
enableSchedulingProfiler,
2722
warnAboutDeprecatedLifecycles,
28-
enableStrictEffects,
2923
enableLazyContextPropagation,
3024
} from 'shared/ReactFeatureFlags';
3125
import ReactStrictModeWarnings from './ReactStrictModeWarnings.old';
@@ -39,12 +33,7 @@ import isArray from 'shared/isArray';
3933
import {REACT_CONTEXT_TYPE, REACT_PROVIDER_TYPE} from 'shared/ReactSymbols';
4034

4135
import {resolveDefaultProps} from './ReactFiberLazyComponent.old';
42-
import {
43-
DebugTracingMode,
44-
NoMode,
45-
StrictLegacyMode,
46-
StrictEffectsMode,
47-
} from './ReactTypeOfMode';
36+
import {DebugTracingMode, StrictLegacyMode} from './ReactTypeOfMode';
4837

4938
import {
5039
enqueueUpdate,
@@ -907,14 +896,7 @@ function mountClassInstance(
907896
}
908897

909898
if (typeof instance.componentDidMount === 'function') {
910-
let fiberFlags: Flags = Update | LayoutStatic;
911-
if (
912-
__DEV__ &&
913-
enableStrictEffects &&
914-
(workInProgress.mode & StrictEffectsMode) !== NoMode
915-
) {
916-
fiberFlags |= MountLayoutDev;
917-
}
899+
const fiberFlags: Flags = Update | LayoutStatic;
918900
workInProgress.flags |= fiberFlags;
919901
}
920902
}
@@ -985,14 +967,7 @@ function resumeMountClassInstance(
985967
// If an update was already in progress, we should schedule an Update
986968
// effect even though we're bailing out, so that cWU/cDU are called.
987969
if (typeof instance.componentDidMount === 'function') {
988-
let fiberFlags: Flags = Update | LayoutStatic;
989-
if (
990-
__DEV__ &&
991-
enableStrictEffects &&
992-
(workInProgress.mode & StrictEffectsMode) !== NoMode
993-
) {
994-
fiberFlags |= MountLayoutDev;
995-
}
970+
const fiberFlags: Flags = Update | LayoutStatic;
996971
workInProgress.flags |= fiberFlags;
997972
}
998973
return false;
@@ -1036,28 +1011,14 @@ function resumeMountClassInstance(
10361011
}
10371012
}
10381013
if (typeof instance.componentDidMount === 'function') {
1039-
let fiberFlags: Flags = Update | LayoutStatic;
1040-
if (
1041-
__DEV__ &&
1042-
enableStrictEffects &&
1043-
(workInProgress.mode & StrictEffectsMode) !== NoMode
1044-
) {
1045-
fiberFlags |= MountLayoutDev;
1046-
}
1014+
const fiberFlags: Flags = Update | LayoutStatic;
10471015
workInProgress.flags |= fiberFlags;
10481016
}
10491017
} else {
10501018
// If an update was already in progress, we should schedule an Update
10511019
// effect even though we're bailing out, so that cWU/cDU are called.
10521020
if (typeof instance.componentDidMount === 'function') {
1053-
let fiberFlags: Flags = Update | LayoutStatic;
1054-
if (
1055-
__DEV__ &&
1056-
enableStrictEffects &&
1057-
(workInProgress.mode & StrictEffectsMode) !== NoMode
1058-
) {
1059-
fiberFlags |= MountLayoutDev;
1060-
}
1021+
const fiberFlags: Flags = Update | LayoutStatic;
10611022
workInProgress.flags |= fiberFlags;
10621023
}
10631024

packages/react-reconciler/src/ReactFiberFlags.js

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,49 @@ import {enableCreateEventHandleAPI} from 'shared/ReactFeatureFlags';
1212
export type Flags = number;
1313

1414
// Don't change these two values. They're used by React Dev Tools.
15-
export const NoFlags = /* */ 0b00000000000000000000000000;
16-
export const PerformedWork = /* */ 0b00000000000000000000000001;
15+
export const NoFlags = /* */ 0b000000000000000000000000;
16+
export const PerformedWork = /* */ 0b000000000000000000000001;
1717

1818
// You can change the rest (and add more).
19-
export const Placement = /* */ 0b00000000000000000000000010;
20-
export const Update = /* */ 0b00000000000000000000000100;
21-
export const ChildDeletion = /* */ 0b00000000000000000000001000;
22-
export const ContentReset = /* */ 0b00000000000000000000010000;
23-
export const Callback = /* */ 0b00000000000000000000100000;
24-
export const DidCapture = /* */ 0b00000000000000000001000000;
25-
export const ForceClientRender = /* */ 0b00000000000000000010000000;
26-
export const Ref = /* */ 0b00000000000000000100000000;
27-
export const Snapshot = /* */ 0b00000000000000001000000000;
28-
export const Passive = /* */ 0b00000000000000010000000000;
29-
export const Hydrating = /* */ 0b00000000000000100000000000;
30-
export const Visibility = /* */ 0b00000000000001000000000000;
31-
export const StoreConsistency = /* */ 0b00000000000010000000000000;
19+
export const Placement = /* */ 0b000000000000000000000010;
20+
export const Update = /* */ 0b000000000000000000000100;
21+
export const ChildDeletion = /* */ 0b000000000000000000001000;
22+
export const ContentReset = /* */ 0b000000000000000000010000;
23+
export const Callback = /* */ 0b000000000000000000100000;
24+
export const DidCapture = /* */ 0b000000000000000001000000;
25+
export const ForceClientRender = /* */ 0b000000000000000010000000;
26+
export const Ref = /* */ 0b000000000000000100000000;
27+
export const Snapshot = /* */ 0b000000000000001000000000;
28+
export const Passive = /* */ 0b000000000000010000000000;
29+
export const Hydrating = /* */ 0b000000000000100000000000;
30+
export const Visibility = /* */ 0b000000000001000000000000;
31+
export const StoreConsistency = /* */ 0b000000000010000000000000;
3232

3333
export const LifecycleEffectMask =
3434
Passive | Update | Callback | Ref | Snapshot | StoreConsistency;
3535

3636
// Union of all commit flags (flags with the lifetime of a particular commit)
37-
export const HostEffectMask = /* */ 0b00000000000011111111111111;
37+
export const HostEffectMask = /* */ 0b000000000011111111111111;
3838

3939
// These are not really side effects, but we still reuse this field.
40-
export const Incomplete = /* */ 0b00000000000100000000000000;
41-
export const ShouldCapture = /* */ 0b00000000001000000000000000;
42-
export const ForceUpdateForLegacySuspense = /* */ 0b00000000010000000000000000;
43-
export const DidPropagateContext = /* */ 0b00000000100000000000000000;
44-
export const NeedsPropagation = /* */ 0b00000001000000000000000000;
45-
export const Forked = /* */ 0b00000010000000000000000000;
40+
export const Incomplete = /* */ 0b000000000100000000000000;
41+
export const ShouldCapture = /* */ 0b000000001000000000000000;
42+
export const ForceUpdateForLegacySuspense = /* */ 0b000000010000000000000000;
43+
export const DidPropagateContext = /* */ 0b000000100000000000000000;
44+
export const NeedsPropagation = /* */ 0b000001000000000000000000;
45+
export const Forked = /* */ 0b000010000000000000000000;
4646

4747
// Static tags describe aspects of a fiber that are not specific to a render,
4848
// e.g. a fiber uses a passive effect (even if there are no updates on this particular render).
4949
// This enables us to defer more work in the unmount case,
5050
// since we can defer traversing the tree during layout to look for Passive effects,
5151
// and instead rely on the static flag as a signal that there may be cleanup work.
52-
export const RefStatic = /* */ 0b00000100000000000000000000;
53-
export const LayoutStatic = /* */ 0b00001000000000000000000000;
54-
export const PassiveStatic = /* */ 0b00010000000000000000000000;
52+
export const RefStatic = /* */ 0b000100000000000000000000;
53+
export const LayoutStatic = /* */ 0b001000000000000000000000;
54+
export const PassiveStatic = /* */ 0b010000000000000000000000;
5555

56-
// These flags allow us to traverse to fibers that have effects on mount
57-
// without traversing the entire tree after every commit for
58-
// double invoking
59-
export const MountLayoutDev = /* */ 0b00100000000000000000000000;
60-
export const MountPassiveDev = /* */ 0b01000000000000000000000000;
61-
export const PlacementDEV = /* */ 0b10000000000000000000000000;
56+
// Flag used to identify newly inserted fibers. It isn't reset after commit unlike `Placement`.
57+
export const PlacementDEV = /* */ 0b100000000000000000000000;
6258

6359
// Groups of flags that are used in the commit phase to skip over trees that
6460
// don't contain effects, by checking subtreeFlags.

packages/react-reconciler/src/ReactFiberHooks.new.js

Lines changed: 10 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,12 @@ import {
2828
enableNewReconciler,
2929
enableCache,
3030
enableUseRefAccessWarning,
31-
enableStrictEffects,
3231
enableLazyContextPropagation,
3332
enableUseMutableSource,
3433
enableTransitionTracing,
3534
} from 'shared/ReactFeatureFlags';
3635

37-
import {
38-
NoMode,
39-
ConcurrentMode,
40-
DebugTracingMode,
41-
StrictEffectsMode,
42-
} from './ReactTypeOfMode';
36+
import {NoMode, ConcurrentMode, DebugTracingMode} from './ReactTypeOfMode';
4337
import {
4438
NoLane,
4539
SyncLane,
@@ -67,8 +61,6 @@ import {readContext, checkIfContextChanged} from './ReactFiberNewContext.new';
6761
import {HostRoot, CacheComponent} from './ReactWorkTags';
6862
import {
6963
LayoutStatic as LayoutStaticEffect,
70-
MountLayoutDev as MountLayoutDevEffect,
71-
MountPassiveDev as MountPassiveDevEffect,
7264
Passive as PassiveEffect,
7365
PassiveStatic as PassiveStaticEffect,
7466
StaticMask as StaticMaskEffect,
@@ -569,22 +561,7 @@ export function bailoutHooks(
569561
lanes: Lanes,
570562
) {
571563
workInProgress.updateQueue = current.updateQueue;
572-
// TODO: Don't need to reset the flags here, because they're reset in the
573-
// complete phase (bubbleProperties).
574-
if (
575-
__DEV__ &&
576-
enableStrictEffects &&
577-
(workInProgress.mode & StrictEffectsMode) !== NoMode
578-
) {
579-
workInProgress.flags &= ~(
580-
MountPassiveDevEffect |
581-
MountLayoutDevEffect |
582-
PassiveEffect |
583-
UpdateEffect
584-
);
585-
} else {
586-
workInProgress.flags &= ~(PassiveEffect | UpdateEffect);
587-
}
564+
workInProgress.flags &= ~(PassiveEffect | UpdateEffect);
588565
current.lanes = removeLanes(current.lanes, lanes);
589566
}
590567

@@ -1702,25 +1679,12 @@ function mountEffect(
17021679
create: () => (() => void) | void,
17031680
deps: Array<mixed> | void | null,
17041681
): void {
1705-
if (
1706-
__DEV__ &&
1707-
enableStrictEffects &&
1708-
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
1709-
) {
1710-
return mountEffectImpl(
1711-
MountPassiveDevEffect | PassiveEffect | PassiveStaticEffect,
1712-
HookPassive,
1713-
create,
1714-
deps,
1715-
);
1716-
} else {
1717-
return mountEffectImpl(
1718-
PassiveEffect | PassiveStaticEffect,
1719-
HookPassive,
1720-
create,
1721-
deps,
1722-
);
1723-
}
1682+
return mountEffectImpl(
1683+
PassiveEffect | PassiveStaticEffect,
1684+
HookPassive,
1685+
create,
1686+
deps,
1687+
);
17241688
}
17251689

17261690
function updateEffect(
@@ -1748,14 +1712,7 @@ function mountLayoutEffect(
17481712
create: () => (() => void) | void,
17491713
deps: Array<mixed> | void | null,
17501714
): void {
1751-
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
1752-
if (
1753-
__DEV__ &&
1754-
enableStrictEffects &&
1755-
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
1756-
) {
1757-
fiberFlags |= MountLayoutDevEffect;
1758-
}
1715+
const fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
17591716
return mountEffectImpl(fiberFlags, HookLayout, create, deps);
17601717
}
17611718

@@ -1815,14 +1772,7 @@ function mountImperativeHandle<T>(
18151772
const effectDeps =
18161773
deps !== null && deps !== undefined ? deps.concat([ref]) : null;
18171774

1818-
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
1819-
if (
1820-
__DEV__ &&
1821-
enableStrictEffects &&
1822-
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
1823-
) {
1824-
fiberFlags |= MountLayoutDevEffect;
1825-
}
1775+
const fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
18261776
return mountEffectImpl(
18271777
fiberFlags,
18281778
HookLayout,

0 commit comments

Comments
 (0)