Use bitwise OR to define flag masks (#20044)
Easier to read, harder to mess up. These expressions get simplified by Closure, so there's no runtime impact.
Andrew Clark committed
Oct 16, 2020 at 15:30 UTC
37cb732c59863297e48f69ac1f6e2ba1aa1886f0
1 file changed
+15
-14
packages/react-reconciler/src/ReactFiberFlags.js
+15
-14
@@ -30,10 +30,9 @@ export const Hydrating = /* */ 0b0000000010000000000;
30
export const HydratingAndUpdate = /* */ 0b0000000010000000100;
31
export const Visibility = /* */ 0b0000000100000000000;
32
33
-// Passive & Update & Callback & Ref & Snapshot
34
-export const LifecycleEffectMask = /* */ 0b0000000001110100100;
33
+export const LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot;
34
36
-// Union of all host effects
35
+// Union of all commit flags (flags with the lifetime of a particular commit)
36
export const HostEffectMask = /* */ 0b0000000111111111111;
37
38
// These are not really side effects, but we still reuse this field.
@@ -50,7 +49,14 @@ export const ForceUpdateForLegacySuspense = /* */ 0b0001000000000000000;
49
// and instead rely on the static flag as a signal that there may be cleanup work.
50
export const PassiveStatic = /* */ 0b0010000000000000000;
51
53
-// Union of side effect groupings as pertains to subtreeFlags
52
+// These flags allow us to traverse to fibers that have effects on mount
53
+// without traversing the entire tree after every commit for
54
+// double invoking
55
+export const MountLayoutDev = /* */ 0b0100000000000000000;
56
+export const MountPassiveDev = /* */ 0b1000000000000000000;
57
+
58
+// Groups of flags that are used in the commit phase to skip over trees that
59
+// don't contain effects, by checking subtreeFlags.
60
61
export const BeforeMutationMask =
62
Snapshot |
@@ -62,17 +68,12 @@ export const BeforeMutationMask =
68
Deletion | Visibility
69
: 0);
70
65
-export const MutationMask = /* */ 0b0000000110010011110;
66
-export const LayoutMask = /* */ 0b0000000000010100100;
67
-export const PassiveMask = /* */ 0b0000000001000001000;
71
+export const MutationMask =
72
+ Placement | Update | Deletion | ContentReset | Ref | Hydrating | Visibility;
73
+export const LayoutMask = Update | Callback | Ref;
74
+export const PassiveMask = Passive | Deletion;
75
76
// Union of tags that don't get reset on clones.
77
// This allows certain concepts to persist without recalculting them,
78
// e.g. whether a subtree contains passive effects or portals.
72
-export const StaticMask = /* */ 0b0010000000000000000;
73
-
74
-// These flags allow us to traverse to fibers that have effects on mount
75
-// without traversing the entire tree after every commit for
76
-// double invoking
77
-export const MountLayoutDev = /* */ 0b0100000000000000000;
78
-export const MountPassiveDev = /* */ 0b1000000000000000000;
79
+export const StaticMask = PassiveStatic;