Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename effect fields #19755

Merged
merged 1 commit into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ module.exports = {
// Disabled because it's also used by the Hook type.
// 'lastEffect',
],
new: ['subtreeTag'],
new: ['subtreeFlags'],
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions fixtures/fiber-debugger/src/Fibers.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ export default function Fibers({fibers, show, graphSettings, ...rest}) {
) : (
<small>Committed</small>
)}
{fiber.effectTag && [
{fiber.flags && [
<br key="br" />,
<small key="small">Effect: {fiber.effectTag}</small>,
<small key="small">Effect: {fiber.flags}</small>,
]}
</div>
</Vertex>,
Expand Down
6 changes: 3 additions & 3 deletions fixtures/fiber-debugger/src/describeFibers.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function getFriendlyTag(tag) {
}
}

function getFriendlyEffect(effectTag) {
function getFriendlyEffect(flags) {
const effects = {
1: 'Performed Work',
2: 'Placement',
Expand All @@ -49,7 +49,7 @@ function getFriendlyEffect(effectTag) {
128: 'Ref',
};
return Object.keys(effects)
.filter(flag => flag & effectTag)
.filter(flag => flag & flags)
.map(flag => effects[flag])
.join(' & ');
}
Expand All @@ -72,7 +72,7 @@ export default function describeFibers(rootFiber, workInProgress) {
...fiber,
id: id,
tag: getFriendlyTag(fiber.tag),
effectTag: getFriendlyEffect(fiber.effectTag),
flags: getFriendlyEffect(fiber.flags),
type: fiber.type && '<' + (fiber.type.name || fiber.type) + '>',
stateNode: `[${typeof fiber.stateNode}]`,
return: acknowledgeFiber(fiber.return),
Expand Down
17 changes: 11 additions & 6 deletions packages/react-devtools-shared/src/backend/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,16 @@ type ReactPriorityLevelsType = {|
|};

type ReactTypeOfSideEffectType = {|
NoEffect: number,
NoFlags: number,
PerformedWork: number,
Placement: number,
|};

function getFiberFlags(fiber: Fiber): number {
// The name of this field changed from "effectTag" to "flags"
return fiber.flags !== undefined ? fiber.flags : (fiber: any).effectTag;
}

// Some environments (e.g. React Native / Hermes) don't support the performance API yet.
const getCurrentTime =
typeof performance === 'object' && typeof performance.now === 'function'
Expand All @@ -127,7 +132,7 @@ export function getInternalReactConstants(
ReactTypeOfWork: WorkTagMap,
|} {
const ReactTypeOfSideEffect: ReactTypeOfSideEffectType = {
NoEffect: 0b00,
NoFlags: 0b00,
PerformedWork: 0b01,
Placement: 0b10,
};
Expand Down Expand Up @@ -416,7 +421,7 @@ export function attach(
ReactTypeOfWork,
ReactTypeOfSideEffect,
} = getInternalReactConstants(renderer.version);
const {NoEffect, PerformedWork, Placement} = ReactTypeOfSideEffect;
const {NoFlags, PerformedWork, Placement} = ReactTypeOfSideEffect;
const {
FunctionComponent,
ClassComponent,
Expand Down Expand Up @@ -944,7 +949,7 @@ export function attach(
// For types that execute user code, we check PerformedWork effect.
// We don't reflect bailouts (either referential or sCU) in DevTools.
// eslint-disable-next-line no-bitwise
return (nextFiber.effectTag & PerformedWork) === PerformedWork;
return (getFiberFlags(nextFiber) & PerformedWork) === PerformedWork;
// Note: ContextConsumer only gets PerformedWork effect in 16.3.3+
// so it won't get highlighted with React 16.3.0 to 16.3.2.
default:
Expand Down Expand Up @@ -1928,12 +1933,12 @@ export function attach(
if (!fiber.alternate) {
// If there is no alternate, this might be a new tree that isn't inserted
// yet. If it is, then it will have a pending insertion effect on it.
if ((node.effectTag & Placement) !== NoEffect) {
if ((getFiberFlags(node) & Placement) !== NoFlags) {
return MOUNTING;
}
while (node.return) {
node = node.return;
if ((node.effectTag & Placement) !== NoEffect) {
if ((getFiberFlags(node) & Placement) !== NoFlags) {
return MOUNTING;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-devtools-shared/src/backend/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type BundleType =
| 1; // DEV

export type WorkTag = number;
export type SideEffectTag = number;
export type WorkFlags = number;
export type ExpirationTime = number;

export type WorkTagMap = {|
Expand Down
10 changes: 5 additions & 5 deletions packages/react-reconciler/src/ReactChildFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {Fiber} from './ReactInternalTypes';
import type {Lanes} from './ReactFiberLane';

import getComponentName from 'shared/getComponentName';
import {Deletion, Placement} from './ReactSideEffectTags';
import {Deletion, Placement} from './ReactFiberFlags';
import {
getIteratorFn,
REACT_ELEMENT_TYPE,
Expand Down Expand Up @@ -280,7 +280,7 @@ function ChildReconciler(shouldTrackSideEffects) {
const deletions = returnFiber.deletions;
if (deletions === null) {
returnFiber.deletions = [childToDelete];
returnFiber.effectTag |= Deletion;
returnFiber.flags |= Deletion;
} else {
deletions.push(childToDelete);
}
Expand Down Expand Up @@ -350,15 +350,15 @@ function ChildReconciler(shouldTrackSideEffects) {
const oldIndex = current.index;
if (oldIndex < lastPlacedIndex) {
// This is a move.
newFiber.effectTag = Placement;
newFiber.flags = Placement;
return lastPlacedIndex;
} else {
// This item can stay in place.
return oldIndex;
}
} else {
// This is an insertion.
newFiber.effectTag = Placement;
newFiber.flags = Placement;
return lastPlacedIndex;
}
}
Expand All @@ -367,7 +367,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// This is simpler for the single child case. We only need to do a
// placement for inserting new children.
if (shouldTrackSideEffects && newFiber.alternate === null) {
newFiber.effectTag = Placement;
newFiber.flags = Placement;
}
return newFiber;
}
Expand Down
10 changes: 5 additions & 5 deletions packages/react-reconciler/src/ReactChildFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {Fiber} from './ReactInternalTypes';
import type {Lanes} from './ReactFiberLane';

import getComponentName from 'shared/getComponentName';
import {Placement, Deletion} from './ReactSideEffectTags';
import {Placement, Deletion} from './ReactFiberFlags';
import {
getIteratorFn,
REACT_ELEMENT_TYPE,
Expand Down Expand Up @@ -290,7 +290,7 @@ function ChildReconciler(shouldTrackSideEffects) {
returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
}
childToDelete.nextEffect = null;
childToDelete.effectTag = Deletion;
childToDelete.flags = Deletion;
}

function deleteRemainingChildren(
Expand Down Expand Up @@ -357,15 +357,15 @@ function ChildReconciler(shouldTrackSideEffects) {
const oldIndex = current.index;
if (oldIndex < lastPlacedIndex) {
// This is a move.
newFiber.effectTag = Placement;
newFiber.flags = Placement;
return lastPlacedIndex;
} else {
// This item can stay in place.
return oldIndex;
}
} else {
// This is an insertion.
newFiber.effectTag = Placement;
newFiber.flags = Placement;
return lastPlacedIndex;
}
}
Expand All @@ -374,7 +374,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// This is simpler for the single child case. We only need to do a
// placement for inserting new children.
if (shouldTrackSideEffects && newFiber.alternate === null) {
newFiber.effectTag = Placement;
newFiber.flags = Placement;
}
return newFiber;
}
Expand Down
22 changes: 11 additions & 11 deletions packages/react-reconciler/src/ReactFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {
enableScopeAPI,
enableBlocksAPI,
} from 'shared/ReactFeatureFlags';
import {NoEffect, Placement, StaticMask} from './ReactSideEffectTags';
import {NoEffect as NoSubtreeEffect} from './ReactSubtreeTags';
import {NoFlags, Placement, StaticMask} from './ReactFiberFlags';
import {NoFlags as NoSubtreeEffect} from './ReactSubtreeFlags';
import {ConcurrentRoot, BlockingRoot} from './ReactRootTags';
import {
IndeterminateComponent,
Expand Down Expand Up @@ -144,8 +144,8 @@ function FiberNode(
this.mode = mode;

// Effects
this.effectTag = NoEffect;
this.subtreeTag = NoSubtreeEffect;
this.flags = NoFlags;
this.subtreeFlags = NoSubtreeEffect;
this.deletions = null;

this.lanes = NoLanes;
Expand Down Expand Up @@ -284,7 +284,7 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
workInProgress.type = current.type;

// We already have an alternate.
workInProgress.subtreeTag = NoSubtreeEffect;
workInProgress.subtreeFlags = NoSubtreeEffect;
workInProgress.deletions = null;

if (enableProfilerTimer) {
Expand All @@ -299,7 +299,7 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {

// Reset all effects except static ones.
// Static effects are not specific to a render.
workInProgress.effectTag = current.effectTag & StaticMask;
workInProgress.flags = current.flags & StaticMask;
workInProgress.childLanes = current.childLanes;
workInProgress.lanes = current.lanes;

Expand Down Expand Up @@ -363,7 +363,7 @@ export function resetWorkInProgress(workInProgress: Fiber, renderLanes: Lanes) {

// Reset the effect tag but keep any Placement tags, since that's something
// that child fiber is setting, not the reconciliation.
workInProgress.effectTag &= Placement;
workInProgress.flags &= Placement;

const current = workInProgress.alternate;
if (current === null) {
Expand All @@ -372,7 +372,7 @@ export function resetWorkInProgress(workInProgress: Fiber, renderLanes: Lanes) {
workInProgress.lanes = renderLanes;

workInProgress.child = null;
workInProgress.subtreeTag = NoSubtreeEffect;
workInProgress.subtreeFlags = NoSubtreeEffect;
workInProgress.memoizedProps = null;
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;
Expand All @@ -393,7 +393,7 @@ export function resetWorkInProgress(workInProgress: Fiber, renderLanes: Lanes) {
workInProgress.lanes = current.lanes;

workInProgress.child = current.child;
workInProgress.subtreeTag = current.subtreeTag;
workInProgress.subtreeFlags = current.subtreeFlags;
workInProgress.deletions = null;
workInProgress.memoizedProps = current.memoizedProps;
workInProgress.memoizedState = current.memoizedState;
Expand Down Expand Up @@ -816,8 +816,8 @@ export function assignFiberPropertiesInDEV(
target.memoizedState = source.memoizedState;
target.dependencies = source.dependencies;
target.mode = source.mode;
target.effectTag = source.effectTag;
target.subtreeTag = source.subtreeTag;
target.flags = source.flags;
target.subtreeFlags = source.subtreeFlags;
target.deletions = source.deletions;
target.lanes = source.lanes;
target.childLanes = source.childLanes;
Expand Down
10 changes: 5 additions & 5 deletions packages/react-reconciler/src/ReactFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
enableScopeAPI,
enableBlocksAPI,
} from 'shared/ReactFeatureFlags';
import {NoEffect, Placement} from './ReactSideEffectTags';
import {NoFlags, Placement} from './ReactFiberFlags';
import {ConcurrentRoot, BlockingRoot} from './ReactRootTags';
import {
IndeterminateComponent,
Expand Down Expand Up @@ -143,7 +143,7 @@ function FiberNode(
this.mode = mode;

// Effects
this.effectTag = NoEffect;
this.flags = NoFlags;
this.nextEffect = null;

this.firstEffect = null;
Expand Down Expand Up @@ -286,7 +286,7 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {

// We already have an alternate.
// Reset the effect tag.
workInProgress.effectTag = NoEffect;
workInProgress.flags = NoFlags;

// The effect list is no longer valid.
workInProgress.nextEffect = null;
Expand Down Expand Up @@ -366,7 +366,7 @@ export function resetWorkInProgress(workInProgress: Fiber, renderLanes: Lanes) {

// Reset the effect tag but keep any Placement tags, since that's something
// that child fiber is setting, not the reconciliation.
workInProgress.effectTag &= Placement;
workInProgress.flags &= Placement;

// The effect list is no longer valid.
workInProgress.nextEffect = null;
Expand Down Expand Up @@ -821,7 +821,7 @@ export function assignFiberPropertiesInDEV(
target.memoizedState = source.memoizedState;
target.dependencies = source.dependencies;
target.mode = source.mode;
target.effectTag = source.effectTag;
target.flags = source.flags;
target.nextEffect = source.nextEffect;
target.firstEffect = source.firstEffect;
target.lastEffect = source.lastEffect;
Expand Down
Loading