Skip to content

Commit d55084c

Browse files
committed
Remove ReactFiberFlags MountLayoutDev and MountPassiveDev
1 parent 5d1ce65 commit d55084c

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,19 +28,13 @@ import {
2828
enableNewReconciler,
2929
enableCache,
3030
enableUseRefAccessWarning,
31-
enableStrictEffects,
3231
enableLazyContextPropagation,
3332
enableUseMutableSource,
3433
enableTransitionTracing,
3534
enableUseMemoCacheHook,
3635
} from 'shared/ReactFeatureFlags';
3736

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

@@ -1707,25 +1684,12 @@ function mountEffect(
17071684
create: () => (() => void) | void,
17081685
deps: Array<mixed> | void | null,
17091686
): void {
1710-
if (
1711-
__DEV__ &&
1712-
enableStrictEffects &&
1713-
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
1714-
) {
1715-
return mountEffectImpl(
1716-
MountPassiveDevEffect | PassiveEffect | PassiveStaticEffect,
1717-
HookPassive,
1718-
create,
1719-
deps,
1720-
);
1721-
} else {
1722-
return mountEffectImpl(
1723-
PassiveEffect | PassiveStaticEffect,
1724-
HookPassive,
1725-
create,
1726-
deps,
1727-
);
1728-
}
1687+
return mountEffectImpl(
1688+
PassiveEffect | PassiveStaticEffect,
1689+
HookPassive,
1690+
create,
1691+
deps,
1692+
);
17291693
}
17301694

17311695
function updateEffect(
@@ -1753,14 +1717,7 @@ function mountLayoutEffect(
17531717
create: () => (() => void) | void,
17541718
deps: Array<mixed> | void | null,
17551719
): void {
1756-
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
1757-
if (
1758-
__DEV__ &&
1759-
enableStrictEffects &&
1760-
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
1761-
) {
1762-
fiberFlags |= MountLayoutDevEffect;
1763-
}
1720+
const fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
17641721
return mountEffectImpl(fiberFlags, HookLayout, create, deps);
17651722
}
17661723

@@ -1820,14 +1777,7 @@ function mountImperativeHandle<T>(
18201777
const effectDeps =
18211778
deps !== null && deps !== undefined ? deps.concat([ref]) : null;
18221779

1823-
let fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
1824-
if (
1825-
__DEV__ &&
1826-
enableStrictEffects &&
1827-
(currentlyRenderingFiber.mode & StrictEffectsMode) !== NoMode
1828-
) {
1829-
fiberFlags |= MountLayoutDevEffect;
1830-
}
1780+
const fiberFlags: Flags = UpdateEffect | LayoutStaticEffect;
18311781
return mountEffectImpl(
18321782
fiberFlags,
18331783
HookLayout,

0 commit comments

Comments
 (0)