diff --git a/.eslintrc.js b/.eslintrc.js index 6eb0eefbda3c3..036df09251979 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -117,7 +117,7 @@ module.exports = { // Disabled because it's also used by the Hook type. // 'lastEffect', ], - new: ['subtreeTag'], + new: ['subtreeFlags'], }, ], }, diff --git a/fixtures/fiber-debugger/src/Fibers.js b/fixtures/fiber-debugger/src/Fibers.js index b6b06e59a7170..fa8387c05d4ce 100644 --- a/fixtures/fiber-debugger/src/Fibers.js +++ b/fixtures/fiber-debugger/src/Fibers.js @@ -324,9 +324,9 @@ export default function Fibers({fibers, show, graphSettings, ...rest}) { ) : ( Committed )} - {fiber.effectTag && [ + {fiber.flags && [
, - Effect: {fiber.effectTag}, + Effect: {fiber.flags}, ]} , diff --git a/fixtures/fiber-debugger/src/describeFibers.js b/fixtures/fiber-debugger/src/describeFibers.js index 0e082f0b07e0c..044380e21bef3 100644 --- a/fixtures/fiber-debugger/src/describeFibers.js +++ b/fixtures/fiber-debugger/src/describeFibers.js @@ -37,7 +37,7 @@ function getFriendlyTag(tag) { } } -function getFriendlyEffect(effectTag) { +function getFriendlyEffect(flags) { const effects = { 1: 'Performed Work', 2: 'Placement', @@ -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(' & '); } @@ -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), diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js index 1f9f1e5f2397c..573ddac2641f6 100644 --- a/packages/react-devtools-shared/src/backend/renderer.js +++ b/packages/react-devtools-shared/src/backend/renderer.js @@ -111,6 +111,11 @@ type ReactTypeOfSideEffectType = {| 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' @@ -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: @@ -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) !== NoEffect) { return MOUNTING; } while (node.return) { node = node.return; - if ((node.effectTag & Placement) !== NoEffect) { + if ((getFiberFlags(node) & Placement) !== NoEffect) { return MOUNTING; } } diff --git a/packages/react-devtools-shared/src/backend/types.js b/packages/react-devtools-shared/src/backend/types.js index 4ae13a294863e..bfa405e1a83da 100644 --- a/packages/react-devtools-shared/src/backend/types.js +++ b/packages/react-devtools-shared/src/backend/types.js @@ -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 = {| diff --git a/packages/react-reconciler/src/ReactChildFiber.new.js b/packages/react-reconciler/src/ReactChildFiber.new.js index ebc3b59ce47fa..463ebefe876e0 100644 --- a/packages/react-reconciler/src/ReactChildFiber.new.js +++ b/packages/react-reconciler/src/ReactChildFiber.new.js @@ -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, @@ -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); } @@ -350,7 +350,7 @@ 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. @@ -358,7 +358,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } else { // This is an insertion. - newFiber.effectTag = Placement; + newFiber.flags = Placement; return lastPlacedIndex; } } @@ -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; } diff --git a/packages/react-reconciler/src/ReactChildFiber.old.js b/packages/react-reconciler/src/ReactChildFiber.old.js index 5ba77f9313ad4..0aea86f033672 100644 --- a/packages/react-reconciler/src/ReactChildFiber.old.js +++ b/packages/react-reconciler/src/ReactChildFiber.old.js @@ -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, @@ -290,7 +290,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; } childToDelete.nextEffect = null; - childToDelete.effectTag = Deletion; + childToDelete.flags = Deletion; } function deleteRemainingChildren( @@ -357,7 +357,7 @@ 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. @@ -365,7 +365,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } else { // This is an insertion. - newFiber.effectTag = Placement; + newFiber.flags = Placement; return lastPlacedIndex; } } @@ -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; } diff --git a/packages/react-reconciler/src/ReactFiber.new.js b/packages/react-reconciler/src/ReactFiber.new.js index dd257b06c3583..cfc027373a423 100644 --- a/packages/react-reconciler/src/ReactFiber.new.js +++ b/packages/react-reconciler/src/ReactFiber.new.js @@ -29,8 +29,8 @@ import { enableScopeAPI, enableBlocksAPI, } from 'shared/ReactFeatureFlags'; -import {NoEffect, Placement, StaticMask} from './ReactSideEffectTags'; -import {NoEffect as NoSubtreeEffect} from './ReactSubtreeTags'; +import {NoEffect, Placement, StaticMask} from './ReactFiberFlags'; +import {NoEffect as NoSubtreeEffect} from './ReactSubtreeFlags'; import {ConcurrentRoot, BlockingRoot} from './ReactRootTags'; import { IndeterminateComponent, @@ -144,8 +144,8 @@ function FiberNode( this.mode = mode; // Effects - this.effectTag = NoEffect; - this.subtreeTag = NoSubtreeEffect; + this.flags = NoEffect; + this.subtreeFlags = NoSubtreeEffect; this.deletions = null; this.lanes = NoLanes; @@ -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) { @@ -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; @@ -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) { @@ -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; @@ -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; @@ -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; diff --git a/packages/react-reconciler/src/ReactFiber.old.js b/packages/react-reconciler/src/ReactFiber.old.js index 3d896efe8e851..b7be099050a5c 100644 --- a/packages/react-reconciler/src/ReactFiber.old.js +++ b/packages/react-reconciler/src/ReactFiber.old.js @@ -29,7 +29,7 @@ import { enableScopeAPI, enableBlocksAPI, } from 'shared/ReactFeatureFlags'; -import {NoEffect, Placement} from './ReactSideEffectTags'; +import {NoEffect, Placement} from './ReactFiberFlags'; import {ConcurrentRoot, BlockingRoot} from './ReactRootTags'; import { IndeterminateComponent, @@ -143,7 +143,7 @@ function FiberNode( this.mode = mode; // Effects - this.effectTag = NoEffect; + this.flags = NoEffect; this.nextEffect = null; this.firstEffect = null; @@ -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 = NoEffect; // The effect list is no longer valid. workInProgress.nextEffect = null; @@ -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; @@ -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; diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.new.js b/packages/react-reconciler/src/ReactFiberBeginWork.new.js index f00e5286751b8..26184180c513b 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.new.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.new.js @@ -64,7 +64,7 @@ import { Ref, Deletion, ForceUpdateForLegacySuspense, -} from './ReactSideEffectTags'; +} from './ReactFiberFlags'; import ReactSharedInternals from 'shared/ReactSharedInternals'; import { debugRenderPhaseSideEffectsForStrictMode, @@ -375,7 +375,7 @@ function updateForwardRef( } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -470,7 +470,7 @@ function updateMemoComponent( } } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; const newChild = createWorkInProgress(currentChild, nextProps); newChild.ref = workInProgress.ref; newChild.return = workInProgress; @@ -549,10 +549,7 @@ function updateSimpleMemoComponent( workInProgress, renderLanes, ); - } else if ( - (current.effectTag & ForceUpdateForLegacySuspense) !== - NoEffect - ) { + } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoEffect) { // This is a special case that only exists for legacy mode. // See https://github.com/facebook/react/pull/19216. didReceiveUpdate = true; @@ -676,7 +673,7 @@ function updateProfiler( renderLanes: Lanes, ) { if (enableProfilerTimer) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, @@ -697,7 +694,7 @@ function markRef(current: Fiber | null, workInProgress: Fiber) { (current !== null && current.ref !== ref) ) { // Schedule a Ref effect - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } } @@ -779,7 +776,7 @@ function updateFunctionComponent( } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -848,7 +845,7 @@ function updateBlock( } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -899,7 +896,7 @@ function updateClassComponent( current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // In the initial pass we might need to construct the instance. constructClassInstance(workInProgress, Component, nextProps); @@ -957,7 +954,7 @@ function finishClassComponent( // Refs should update even if shouldComponentUpdate returns false markRef(current, workInProgress); - const didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect; + const didCaptureError = (workInProgress.flags & DidCapture) !== NoEffect; if (!shouldUpdate && !didCaptureError) { // Context providers should defer to sCU for rendering @@ -1009,7 +1006,7 @@ function finishClassComponent( } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; if (current !== null && didCaptureError) { // If we're recovering from an error, reconcile without reusing any of // the existing children. Conceptually, the normal children and the children @@ -1111,7 +1108,7 @@ function updateHostRoot(current, workInProgress, renderLanes) { // Conceptually this is similar to Placement in that a new subtree is // inserted into the React tree here. It just happens to not need DOM // mutations because it already exists. - node.effectTag = (node.effectTag & ~Placement) | Hydrating; + node.flags = (node.flags & ~Placement) | Hydrating; node = node.sibling; } } else { @@ -1150,7 +1147,7 @@ function updateHostComponent( } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { // If we're switching from a direct text child to a normal child, or to // empty, we need to schedule the text content to be reset. - workInProgress.effectTag |= ContentReset; + workInProgress.flags |= ContentReset; } markRef(current, workInProgress); @@ -1182,7 +1179,7 @@ function mountLazyComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } const props = workInProgress.pendingProps; @@ -1318,7 +1315,7 @@ function mountIncompleteClassComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // Promote the fiber to a class and try rendering again. @@ -1365,7 +1362,7 @@ function mountIndeterminateComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } const props = workInProgress.pendingProps; @@ -1426,7 +1423,7 @@ function mountIndeterminateComponent( ); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; if (__DEV__) { // Support for module components is deprecated and is removed behind a flag. @@ -1698,14 +1695,14 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { // This is used by DevTools to force a boundary to suspend. if (__DEV__) { if (shouldSuspend(workInProgress)) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } } let suspenseContext: SuspenseContext = suspenseStackCursor.current; let showFallback = false; - const didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect; + const didSuspend = (workInProgress.flags & DidCapture) !== NoEffect; if ( didSuspend || @@ -1719,7 +1716,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. showFallback = true; - workInProgress.effectTag &= ~DidCapture; + workInProgress.flags &= ~DidCapture; } else { // Attempting the main content if ( @@ -1844,7 +1841,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { workInProgress.child = current.child; // The dehydrated completion pass expects this flag to be there // but the normal suspense pass doesn't. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; return null; } else { // Suspended but we should no longer be in dehydrated mode. @@ -2067,7 +2064,7 @@ function updateSuspensePrimaryChildren( if (deletions === null) { workInProgress.deletions = [currentFallbackChildFragment]; // TODO (effects) Rename this to better reflect its new usage (e.g. ChildDeletions) - workInProgress.effectTag |= Deletion; + workInProgress.flags |= Deletion; } else { deletions.push(currentFallbackChildFragment); } @@ -2150,7 +2147,7 @@ function updateSuspenseFallbackChildren( ); // Needs a placement effect because the parent (the Suspense boundary) already // mounted but this is a new fiber. - fallbackChildFragment.effectTag |= Placement; + fallbackChildFragment.flags |= Placement; } fallbackChildFragment.return = workInProgress; @@ -2179,7 +2176,7 @@ function retrySuspenseComponentWithoutHydrating( ); // Needs a placement effect because the parent (the Suspense boundary) already // mounted but this is a new fiber. - primaryChildFragment.effectTag |= Placement; + primaryChildFragment.flags |= Placement; workInProgress.memoizedState = null; return primaryChildFragment; @@ -2207,7 +2204,7 @@ function mountSuspenseFallbackAfterRetryWithoutHydrating( ); // Needs a placement effect because the parent (the Suspense // boundary) already mounted but this is a new fiber. - fallbackChildFragment.effectTag |= Placement; + fallbackChildFragment.flags |= Placement; primaryChildFragment.return = workInProgress; fallbackChildFragment.return = workInProgress; @@ -2360,7 +2357,7 @@ function updateDehydratedSuspenseComponent( // on the client than if we just leave it alone. If the server times out or errors // these should update this boundary to the permanent Fallback state instead. // Mark it as having captured (i.e. suspended). - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; // Leave the child in place. I.e. the dehydrated fragment. workInProgress.child = current.child; // Register a callback to retry this boundary once the server has sent the result. @@ -2389,7 +2386,7 @@ function updateDehydratedSuspenseComponent( // Conceptually this is similar to Placement in that a new subtree is // inserted into the React tree here. It just happens to not need DOM // mutations because it already exists. - primaryChildFragment.effectTag |= Hydrating; + primaryChildFragment.flags |= Hydrating; return primaryChildFragment; } } @@ -2675,10 +2672,10 @@ function updateSuspenseListComponent( suspenseContext, ForceSuspenseFallback, ); - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } else { const didSuspendBefore = - current !== null && (current.effectTag & DidCapture) !== NoEffect; + current !== null && (current.flags & DidCapture) !== NoEffect; if (didSuspendBefore) { // If we previously forced a fallback, we need to schedule work // on any nested boundaries to let them know to try to render @@ -2918,7 +2915,7 @@ function updateContextConsumer( } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, newChildren, renderLanes); return workInProgress.child; } @@ -3023,12 +3020,12 @@ function remountFiber( if (deletions === null) { returnFiber.deletions = [current]; // TODO (effects) Rename this to better reflect its new usage (e.g. ChildDeletions) - returnFiber.effectTag |= Deletion; + returnFiber.flags |= Deletion; } else { deletions.push(current); } - newWorkInProgress.effectTag |= Placement; + newWorkInProgress.flags |= Placement; // Restart work from the new fiber. return newWorkInProgress; @@ -3117,7 +3114,7 @@ function beginWork( workInProgress.childLanes, ); if (hasChildWork) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Reset effect durations for the next eventual effect phase. @@ -3139,7 +3136,7 @@ function beginWork( // We know that this component will suspend again because if it has // been unsuspended it has committed as a resolved Suspense component. // If it needs to be retried, it should have work scheduled on it. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; // We should never render the children of a dehydrated boundary until we // upgrade it. We return null instead of bailoutOnAlreadyFinishedWork. return null; @@ -3191,8 +3188,7 @@ function beginWork( break; } case SuspenseListComponent: { - const didSuspendBefore = - (current.effectTag & DidCapture) !== NoEffect; + const didSuspendBefore = (current.flags & DidCapture) !== NoEffect; const hasChildWork = includesSomeLane( renderLanes, @@ -3215,7 +3211,7 @@ function beginWork( // If none of the children had any work, that means that none of // them got retried so they'll still be blocked in the same way // as before. We can fast bail out. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } // If nothing suspended before and we're rendering the same children, @@ -3255,7 +3251,7 @@ function beginWork( } return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else { - if ((current.effectTag & ForceUpdateForLegacySuspense) !== NoEffect) { + if ((current.flags & ForceUpdateForLegacySuspense) !== NoEffect) { // This is a special case that only exists for legacy mode. // See https://github.com/facebook/react/pull/19216. didReceiveUpdate = true; diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.old.js b/packages/react-reconciler/src/ReactFiberBeginWork.old.js index 1888c03c910ed..aa101e596f685 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.old.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.old.js @@ -64,7 +64,7 @@ import { Ref, Deletion, ForceUpdateForLegacySuspense, -} from './ReactSideEffectTags'; +} from './ReactFiberFlags'; import ReactSharedInternals from 'shared/ReactSharedInternals'; import { debugRenderPhaseSideEffectsForStrictMode, @@ -375,7 +375,7 @@ function updateForwardRef( } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -470,7 +470,7 @@ function updateMemoComponent( } } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; const newChild = createWorkInProgress(currentChild, nextProps); newChild.ref = workInProgress.ref; newChild.return = workInProgress; @@ -549,10 +549,7 @@ function updateSimpleMemoComponent( workInProgress, renderLanes, ); - } else if ( - (current.effectTag & ForceUpdateForLegacySuspense) !== - NoEffect - ) { + } else if ((current.flags & ForceUpdateForLegacySuspense) !== NoEffect) { // This is a special case that only exists for legacy mode. // See https://github.com/facebook/react/pull/19216. didReceiveUpdate = true; @@ -676,7 +673,7 @@ function updateProfiler( renderLanes: Lanes, ) { if (enableProfilerTimer) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, @@ -697,7 +694,7 @@ function markRef(current: Fiber | null, workInProgress: Fiber) { (current !== null && current.ref !== ref) ) { // Schedule a Ref effect - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } } @@ -779,7 +776,7 @@ function updateFunctionComponent( } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -848,7 +845,7 @@ function updateBlock( } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, nextChildren, renderLanes); return workInProgress.child; } @@ -899,7 +896,7 @@ function updateClassComponent( current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // In the initial pass we might need to construct the instance. constructClassInstance(workInProgress, Component, nextProps); @@ -957,7 +954,7 @@ function finishClassComponent( // Refs should update even if shouldComponentUpdate returns false markRef(current, workInProgress); - const didCaptureError = (workInProgress.effectTag & DidCapture) !== NoEffect; + const didCaptureError = (workInProgress.flags & DidCapture) !== NoEffect; if (!shouldUpdate && !didCaptureError) { // Context providers should defer to sCU for rendering @@ -1009,7 +1006,7 @@ function finishClassComponent( } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; if (current !== null && didCaptureError) { // If we're recovering from an error, reconcile without reusing any of // the existing children. Conceptually, the normal children and the children @@ -1111,7 +1108,7 @@ function updateHostRoot(current, workInProgress, renderLanes) { // Conceptually this is similar to Placement in that a new subtree is // inserted into the React tree here. It just happens to not need DOM // mutations because it already exists. - node.effectTag = (node.effectTag & ~Placement) | Hydrating; + node.flags = (node.flags & ~Placement) | Hydrating; node = node.sibling; } } else { @@ -1150,7 +1147,7 @@ function updateHostComponent( } else if (prevProps !== null && shouldSetTextContent(type, prevProps)) { // If we're switching from a direct text child to a normal child, or to // empty, we need to schedule the text content to be reset. - workInProgress.effectTag |= ContentReset; + workInProgress.flags |= ContentReset; } markRef(current, workInProgress); @@ -1182,7 +1179,7 @@ function mountLazyComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } const props = workInProgress.pendingProps; @@ -1318,7 +1315,7 @@ function mountIncompleteClassComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } // Promote the fiber to a class and try rendering again. @@ -1365,7 +1362,7 @@ function mountIndeterminateComponent( _current.alternate = null; workInProgress.alternate = null; // Since this is conceptually a new fiber, schedule a Placement effect - workInProgress.effectTag |= Placement; + workInProgress.flags |= Placement; } const props = workInProgress.pendingProps; @@ -1426,7 +1423,7 @@ function mountIndeterminateComponent( ); } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; if (__DEV__) { // Support for module components is deprecated and is removed behind a flag. @@ -1698,14 +1695,14 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { // This is used by DevTools to force a boundary to suspend. if (__DEV__) { if (shouldSuspend(workInProgress)) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } } let suspenseContext: SuspenseContext = suspenseStackCursor.current; let showFallback = false; - const didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect; + const didSuspend = (workInProgress.flags & DidCapture) !== NoEffect; if ( didSuspend || @@ -1719,7 +1716,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. showFallback = true; - workInProgress.effectTag &= ~DidCapture; + workInProgress.flags &= ~DidCapture; } else { // Attempting the main content if ( @@ -1844,7 +1841,7 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { workInProgress.child = current.child; // The dehydrated completion pass expects this flag to be there // but the normal suspense pass doesn't. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; return null; } else { // Suspended but we should no longer be in dehydrated mode. @@ -2064,7 +2061,7 @@ function updateSuspensePrimaryChildren( if (currentFallbackChildFragment !== null) { // Delete the fallback child fragment currentFallbackChildFragment.nextEffect = null; - currentFallbackChildFragment.effectTag = Deletion; + currentFallbackChildFragment.flags = Deletion; workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; } @@ -2156,7 +2153,7 @@ function updateSuspenseFallbackChildren( ); // Needs a placement effect because the parent (the Suspense boundary) already // mounted but this is a new fiber. - fallbackChildFragment.effectTag |= Placement; + fallbackChildFragment.flags |= Placement; } fallbackChildFragment.return = workInProgress; @@ -2185,7 +2182,7 @@ function retrySuspenseComponentWithoutHydrating( ); // Needs a placement effect because the parent (the Suspense boundary) already // mounted but this is a new fiber. - primaryChildFragment.effectTag |= Placement; + primaryChildFragment.flags |= Placement; workInProgress.memoizedState = null; return primaryChildFragment; @@ -2213,7 +2210,7 @@ function mountSuspenseFallbackAfterRetryWithoutHydrating( ); // Needs a placement effect because the parent (the Suspense // boundary) already mounted but this is a new fiber. - fallbackChildFragment.effectTag |= Placement; + fallbackChildFragment.flags |= Placement; primaryChildFragment.return = workInProgress; fallbackChildFragment.return = workInProgress; @@ -2366,7 +2363,7 @@ function updateDehydratedSuspenseComponent( // on the client than if we just leave it alone. If the server times out or errors // these should update this boundary to the permanent Fallback state instead. // Mark it as having captured (i.e. suspended). - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; // Leave the child in place. I.e. the dehydrated fragment. workInProgress.child = current.child; // Register a callback to retry this boundary once the server has sent the result. @@ -2395,7 +2392,7 @@ function updateDehydratedSuspenseComponent( // Conceptually this is similar to Placement in that a new subtree is // inserted into the React tree here. It just happens to not need DOM // mutations because it already exists. - primaryChildFragment.effectTag |= Hydrating; + primaryChildFragment.flags |= Hydrating; return primaryChildFragment; } } @@ -2684,10 +2681,10 @@ function updateSuspenseListComponent( suspenseContext, ForceSuspenseFallback, ); - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } else { const didSuspendBefore = - current !== null && (current.effectTag & DidCapture) !== NoEffect; + current !== null && (current.flags & DidCapture) !== NoEffect; if (didSuspendBefore) { // If we previously forced a fallback, we need to schedule work // on any nested boundaries to let them know to try to render @@ -2930,7 +2927,7 @@ function updateContextConsumer( } // React DevTools reads this flag. - workInProgress.effectTag |= PerformedWork; + workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, newChildren, renderLanes); return workInProgress.child; } @@ -3039,9 +3036,9 @@ function remountFiber( returnFiber.firstEffect = returnFiber.lastEffect = current; } current.nextEffect = null; - current.effectTag = Deletion; + current.flags = Deletion; - newWorkInProgress.effectTag |= Placement; + newWorkInProgress.flags |= Placement; // Restart work from the new fiber. return newWorkInProgress; @@ -3130,7 +3127,7 @@ function beginWork( workInProgress.childLanes, ); if (hasChildWork) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Reset effect durations for the next eventual effect phase. @@ -3152,7 +3149,7 @@ function beginWork( // We know that this component will suspend again because if it has // been unsuspended it has committed as a resolved Suspense component. // If it needs to be retried, it should have work scheduled on it. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; // We should never render the children of a dehydrated boundary until we // upgrade it. We return null instead of bailoutOnAlreadyFinishedWork. return null; @@ -3204,8 +3201,7 @@ function beginWork( break; } case SuspenseListComponent: { - const didSuspendBefore = - (current.effectTag & DidCapture) !== NoEffect; + const didSuspendBefore = (current.flags & DidCapture) !== NoEffect; const hasChildWork = includesSomeLane( renderLanes, @@ -3228,7 +3224,7 @@ function beginWork( // If none of the children had any work, that means that none of // them got retried so they'll still be blocked in the same way // as before. We can fast bail out. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; } // If nothing suspended before and we're rendering the same children, @@ -3269,7 +3265,7 @@ function beginWork( } return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } else { - if ((current.effectTag & ForceUpdateForLegacySuspense) !== NoEffect) { + if ((current.flags & ForceUpdateForLegacySuspense) !== NoEffect) { // This is a special case that only exists for legacy mode. // See https://github.com/facebook/react/pull/19216. didReceiveUpdate = true; diff --git a/packages/react-reconciler/src/ReactFiberClassComponent.new.js b/packages/react-reconciler/src/ReactFiberClassComponent.new.js index c4a84b670207c..4e58dd71f3dc6 100644 --- a/packages/react-reconciler/src/ReactFiberClassComponent.new.js +++ b/packages/react-reconciler/src/ReactFiberClassComponent.new.js @@ -12,7 +12,7 @@ import type {Lanes} from './ReactFiberLane'; import type {UpdateQueue} from './ReactUpdateQueue.new'; import * as React from 'react'; -import {Update, Snapshot} from './ReactSideEffectTags'; +import {Update, Snapshot} from './ReactFiberFlags'; import { debugRenderPhaseSideEffectsForStrictMode, disableLegacyContext, @@ -890,7 +890,7 @@ function mountClassInstance( } if (typeof instance.componentDidMount === 'function') { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -960,7 +960,7 @@ function resumeMountClassInstance( // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === 'function') { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } return false; } @@ -1003,13 +1003,13 @@ function resumeMountClassInstance( } } if (typeof instance.componentDidMount === 'function') { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } else { // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === 'function') { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // If shouldComponentUpdate returned false, we should still update the @@ -1106,7 +1106,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if (typeof instance.getSnapshotBeforeUpdate === 'function') { @@ -1114,7 +1114,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } return false; @@ -1158,10 +1158,10 @@ function updateClassInstance( } } if (typeof instance.componentDidUpdate === 'function') { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } if (typeof instance.getSnapshotBeforeUpdate === 'function') { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } else { // If an update was already in progress, we should schedule an Update @@ -1171,7 +1171,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if (typeof instance.getSnapshotBeforeUpdate === 'function') { @@ -1179,7 +1179,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } diff --git a/packages/react-reconciler/src/ReactFiberClassComponent.old.js b/packages/react-reconciler/src/ReactFiberClassComponent.old.js index ad8c0b153d784..c5f3527419490 100644 --- a/packages/react-reconciler/src/ReactFiberClassComponent.old.js +++ b/packages/react-reconciler/src/ReactFiberClassComponent.old.js @@ -12,7 +12,7 @@ import type {Lanes} from './ReactFiberLane'; import type {UpdateQueue} from './ReactUpdateQueue.old'; import * as React from 'react'; -import {Update, Snapshot} from './ReactSideEffectTags'; +import {Update, Snapshot} from './ReactFiberFlags'; import { debugRenderPhaseSideEffectsForStrictMode, disableLegacyContext, @@ -890,7 +890,7 @@ function mountClassInstance( } if (typeof instance.componentDidMount === 'function') { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } @@ -960,7 +960,7 @@ function resumeMountClassInstance( // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === 'function') { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } return false; } @@ -1003,13 +1003,13 @@ function resumeMountClassInstance( } } if (typeof instance.componentDidMount === 'function') { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } else { // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidMount === 'function') { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // If shouldComponentUpdate returned false, we should still update the @@ -1106,7 +1106,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if (typeof instance.getSnapshotBeforeUpdate === 'function') { @@ -1114,7 +1114,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } return false; @@ -1158,10 +1158,10 @@ function updateClassInstance( } } if (typeof instance.componentDidUpdate === 'function') { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } if (typeof instance.getSnapshotBeforeUpdate === 'function') { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } else { // If an update was already in progress, we should schedule an Update @@ -1171,7 +1171,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if (typeof instance.getSnapshotBeforeUpdate === 'function') { @@ -1179,7 +1179,7 @@ function updateClassInstance( unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState ) { - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.new.js b/packages/react-reconciler/src/ReactFiberCommitWork.new.js index 063ff6fe49688..1a6f76b276f5c 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.new.js @@ -27,7 +27,7 @@ import type { import type {Wakeable} from 'shared/ReactTypes'; import type {ReactPriorityLevel} from './ReactInternalTypes'; import type {OffscreenState} from './ReactFiberOffscreenComponent'; -import type {HookEffectTag} from './ReactHookEffectTags'; +import type {HookFlags} from './ReactHookEffectTags'; import {unstable_wrap as Schedule_tracing_wrap} from 'scheduler/tracing'; import { @@ -71,7 +71,7 @@ import { Placement, Snapshot, Update, -} from './ReactSideEffectTags'; +} from './ReactFiberFlags'; import getComponentName from 'shared/getComponentName'; import invariant from 'shared/invariant'; @@ -131,9 +131,9 @@ import { } from './ReactHookEffectTags'; import {didWarnAboutReassigningProps} from './ReactFiberBeginWork.new'; import { - NoEffect as NoSubtreeTag, - Passive as PassiveSubtreeTag, -} from './ReactSubtreeTags'; + NoEffect as NoSubtreeFlags, + Passive as PassiveSubtreeFlags, +} from './ReactSubtreeFlags'; let didWarnAboutUndefinedSnapshotBeforeUpdate: Set | null = null; if (__DEV__) { @@ -243,7 +243,7 @@ function commitBeforeMutationLifeCycles( return; } case ClassComponent: { - if (finishedWork.effectTag & Snapshot) { + if (finishedWork.flags & Snapshot) { if (current !== null) { const prevProps = current.memoizedProps; const prevState = current.memoizedState; @@ -302,7 +302,7 @@ function commitBeforeMutationLifeCycles( } case HostRoot: { if (supportsMutation) { - if (finishedWork.effectTag & Snapshot) { + if (finishedWork.flags & Snapshot) { const root = finishedWork.stateNode; clearContainer(root.containerInfo); } @@ -324,7 +324,7 @@ function commitBeforeMutationLifeCycles( } function commitHookEffectListUnmount( - tag: HookEffectTag, + tag: HookFlags, finishedWork: Fiber, nearestMountedAncestor: Fiber | null, ) { @@ -350,7 +350,7 @@ function commitHookEffectListUnmount( // TODO: Remove this duplication. function commitHookEffectListUnmount2( // Tags to check for when deciding whether to unmount. e.g. to skip over layout effects - hookEffectTag: HookEffectTag, + hookFlags: HookFlags, fiber: Fiber, nearestMountedAncestor: Fiber | null, ): void { @@ -361,7 +361,7 @@ function commitHookEffectListUnmount2( let effect = firstEffect; do { const {next, tag} = effect; - if ((tag & hookEffectTag) === hookEffectTag) { + if ((tag & hookFlags) === hookFlags) { const destroy = effect.destroy; if (destroy !== undefined) { effect.destroy = undefined; @@ -383,7 +383,7 @@ function commitHookEffectListUnmount2( } } -function commitHookEffectListMount(tag: HookEffectTag, finishedWork: Fiber) { +function commitHookEffectListMount(tag: HookFlags, finishedWork: Fiber) { const updateQueue: FunctionComponentUpdateQueue | null = (finishedWork.updateQueue: any); const lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; if (lastEffect !== null) { @@ -516,7 +516,7 @@ export function commitPassiveEffectDurations( ): void { if (enableProfilerTimer && enableProfilerCommitHooks) { // Only Profilers with work in their subtree will have an Update effect scheduled. - if ((finishedWork.effectTag & Update) !== NoEffect) { + if ((finishedWork.flags & Update) !== NoEffect) { switch (finishedWork.tag) { case Profiler: { const {passiveEffectDuration} = finishedWork.stateNode; @@ -595,14 +595,17 @@ function commitLifeCycles( commitHookEffectListMount(HookLayout | HookHasEffect, finishedWork); } - if ((finishedWork.subtreeTag & PassiveSubtreeTag) !== NoSubtreeTag) { + if ( + (finishedWork.subtreeFlags & PassiveSubtreeFlags) !== + NoSubtreeFlags + ) { schedulePassiveEffectCallback(); } return; } case ClassComponent: { const instance = finishedWork.stateNode; - if (finishedWork.effectTag & Update) { + if (finishedWork.flags & Update) { if (current === null) { // We could update instance props and state here, // but instead we rely on them being set during last render. @@ -778,7 +781,7 @@ function commitLifeCycles( // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. - if (current === null && finishedWork.effectTag & Update) { + if (current === null && finishedWork.flags & Update) { const type = finishedWork.type; const props = finishedWork.memoizedProps; commitMount(instance, type, props, finishedWork); @@ -1246,7 +1249,7 @@ function getHostSibling(fiber: Fiber): ?Instance { ) { // If it is not host node and, we might have a host node inside it. // Try to search down until we find one. - if (node.effectTag & Placement) { + if (node.flags & Placement) { // If we don't have a child, try the siblings instead. continue siblings; } @@ -1260,7 +1263,7 @@ function getHostSibling(fiber: Fiber): ?Instance { } } // Check if this host node is stable or about to be placed. - if (!(node.effectTag & Placement)) { + if (!(node.flags & Placement)) { // Found it! return node.stateNode; } @@ -1305,11 +1308,11 @@ function commitPlacement(finishedWork: Fiber): void { 'in React. Please file an issue.', ); } - if (parentFiber.effectTag & ContentReset) { + if (parentFiber.flags & ContentReset) { // Reset the text content of the parent before doing any insertions resetTextContent(parent); // Clear ContentReset from the effect tag - parentFiber.effectTag &= ~ContentReset; + parentFiber.flags &= ~ContentReset; } const before = getHostSibling(finishedWork); diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.old.js b/packages/react-reconciler/src/ReactFiberCommitWork.old.js index e0f8f5fb8373d..5ddeed370aa98 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.old.js @@ -67,7 +67,7 @@ import { Placement, Snapshot, Update, -} from './ReactSideEffectTags'; +} from './ReactFiberFlags'; import getComponentName from 'shared/getComponentName'; import invariant from 'shared/invariant'; @@ -234,7 +234,7 @@ function commitBeforeMutationLifeCycles( return; } case ClassComponent: { - if (finishedWork.effectTag & Snapshot) { + if (finishedWork.flags & Snapshot) { if (current !== null) { const prevProps = current.memoizedProps; const prevState = current.memoizedState; @@ -293,7 +293,7 @@ function commitBeforeMutationLifeCycles( } case HostRoot: { if (supportsMutation) { - if (finishedWork.effectTag & Snapshot) { + if (finishedWork.flags & Snapshot) { const root = finishedWork.stateNode; clearContainer(root.containerInfo); } @@ -410,7 +410,7 @@ export function commitPassiveEffectDurations( ): void { if (enableProfilerTimer && enableProfilerCommitHooks) { // Only Profilers with work in their subtree will have an Update effect scheduled. - if ((finishedWork.effectTag & Update) !== NoEffect) { + if ((finishedWork.flags & Update) !== NoEffect) { switch (finishedWork.tag) { case Profiler: { const {passiveEffectDuration} = finishedWork.stateNode; @@ -494,7 +494,7 @@ function commitLifeCycles( } case ClassComponent: { const instance = finishedWork.stateNode; - if (finishedWork.effectTag & Update) { + if (finishedWork.flags & Update) { if (current === null) { // We could update instance props and state here, // but instead we rely on them being set during last render. @@ -670,7 +670,7 @@ function commitLifeCycles( // (eg DOM renderer may schedule auto-focus for inputs and form controls). // These effects should only be committed when components are first mounted, // aka when there is no current/alternate. - if (current === null && finishedWork.effectTag & Update) { + if (current === null && finishedWork.flags & Update) { const type = finishedWork.type; const props = finishedWork.memoizedProps; commitMount(instance, type, props, finishedWork); @@ -1148,7 +1148,7 @@ function getHostSibling(fiber: Fiber): ?Instance { ) { // If it is not host node and, we might have a host node inside it. // Try to search down until we find one. - if (node.effectTag & Placement) { + if (node.flags & Placement) { // If we don't have a child, try the siblings instead. continue siblings; } @@ -1162,7 +1162,7 @@ function getHostSibling(fiber: Fiber): ?Instance { } } // Check if this host node is stable or about to be placed. - if (!(node.effectTag & Placement)) { + if (!(node.flags & Placement)) { // Found it! return node.stateNode; } @@ -1207,11 +1207,11 @@ function commitPlacement(finishedWork: Fiber): void { 'in React. Please file an issue.', ); } - if (parentFiber.effectTag & ContentReset) { + if (parentFiber.flags & ContentReset) { // Reset the text content of the parent before doing any insertions resetTextContent(parent); // Clear ContentReset from the effect tag - parentFiber.effectTag &= ~ContentReset; + parentFiber.flags &= ~ContentReset; } const before = getHostSibling(finishedWork); diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.new.js b/packages/react-reconciler/src/ReactFiberCompleteWork.new.js index da1a97cab9312..9e1f30a3e1c58 100644 --- a/packages/react-reconciler/src/ReactFiberCompleteWork.new.js +++ b/packages/react-reconciler/src/ReactFiberCompleteWork.new.js @@ -66,8 +66,8 @@ import { DidCapture, Snapshot, MutationMask, -} from './ReactSideEffectTags'; -import {NoEffect as NoSubtreeTag, Mutation} from './ReactSubtreeTags'; +} from './ReactFiberFlags'; +import {NoEffect as NoSubtreeFlags, Mutation} from './ReactSubtreeFlags'; import invariant from 'shared/invariant'; import { @@ -148,11 +148,11 @@ import {transferActualDuration} from './ReactProfilerTimer.new'; function markUpdate(workInProgress: Fiber) { // Tag the fiber with an update effect. This turns a Placement into // a PlacementAndUpdate. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } function markRef(workInProgress: Fiber) { - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } function hadNoMutationsEffects(current: null | Fiber, completedWork: Fiber) { @@ -163,10 +163,10 @@ function hadNoMutationsEffects(current: null | Fiber, completedWork: Fiber) { let child = completedWork.child; while (child !== null) { - if ((child.effectTag & MutationMask) !== NoEffect) { + if ((child.flags & MutationMask) !== NoEffect) { return false; } - if ((child.subtreeTag & Mutation) !== NoSubtreeTag) { + if ((child.subtreeFlags & Mutation) !== NoSubtreeFlags) { return false; } child = child.sibling; @@ -318,7 +318,7 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - if ((node.effectTag & Update) !== NoEffect) { + if ((node.flags & Update) !== NoEffect) { // Need to toggle the visibility of the primary children. const newIsHidden = node.memoizedState !== null; if (newIsHidden) { @@ -412,7 +412,7 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - if ((node.effectTag & Update) !== NoEffect) { + if ((node.flags & Update) !== NoEffect) { // Need to toggle the visibility of the primary children. const newIsHidden = node.memoizedState !== null; if (newIsHidden) { @@ -717,7 +717,7 @@ function completeWork( // This handles the case of React rendering into a container with previous children. // It's also safe to do for updates too, because current.child would only be null // if the previous render was null (so the the container would already be empty). - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } updateHostContainer(current, workInProgress); @@ -863,7 +863,7 @@ function completeWork( // However, in some of those paths, we might have reentered a hydration state // and then we might be inside a hydration state. In that case, we'll need to exit out of it. resetHydrationState(); - if ((workInProgress.effectTag & DidCapture) === NoEffect) { + if ((workInProgress.flags & DidCapture) === NoEffect) { // This boundary did not suspend so it's now hydrated and unsuspended. workInProgress.memoizedState = null; } @@ -872,13 +872,13 @@ function completeWork( // It's also a signal to replay events and the suspense callback. // If something suspended, schedule an effect to attach retry listeners. // So we might as well always mark this. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; return null; } } } - if ((workInProgress.effectTag & DidCapture) !== NoEffect) { + if ((workInProgress.flags & DidCapture) !== NoEffect) { // Something suspended. Re-render with the fallback children. workInProgress.lanes = renderLanes; // Do not reset the effect list. @@ -943,7 +943,7 @@ function completeWork( // If this boundary just timed out, schedule an effect to attach a // retry listener to the promise. This flag is also used to hide the // primary children. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if (supportsMutation) { @@ -954,7 +954,7 @@ function completeWork( // primary children. In mutation mode, we also need the flag to // *unhide* children that were previously hidden, so check if this // is currently timed out, too. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if ( @@ -963,7 +963,7 @@ function completeWork( workInProgress.memoizedProps.suspenseCallback != null ) { // Always notify the callback - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } return null; } @@ -999,8 +999,7 @@ function completeWork( return null; } - let didSuspendAlready = - (workInProgress.effectTag & DidCapture) !== NoEffect; + let didSuspendAlready = (workInProgress.flags & DidCapture) !== NoEffect; const renderedTail = renderState.rendering; if (renderedTail === null) { @@ -1019,14 +1018,14 @@ function completeWork( // findFirstSuspended. const cannotBeSuspended = renderHasNotSuspendedYet() && - (current === null || (current.effectTag & DidCapture) === NoEffect); + (current === null || (current.flags & DidCapture) === NoEffect); if (!cannotBeSuspended) { let row = workInProgress.child; while (row !== null) { const suspended = findFirstSuspended(row); if (suspended !== null) { didSuspendAlready = true; - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as @@ -1044,13 +1043,13 @@ function completeWork( const newThennables = suspended.updateQueue; if (newThennables !== null) { workInProgress.updateQueue = newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Rerender the whole list, but this time, we'll force fallbacks // to stay in place. // Reset the child fibers to their original state. - workInProgress.subtreeTag = NoEffect; + workInProgress.subtreeFlags = NoEffect; resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately @@ -1072,7 +1071,7 @@ function completeWork( // We have already passed our CPU deadline but we still have rows // left in the tail. We'll just give up further attempts to render // the main content and only render fallbacks. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; cutOffTailIfNeeded(renderState, false); @@ -1099,7 +1098,7 @@ function completeWork( if (!didSuspendAlready) { const suspended = findFirstSuspended(renderedTail); if (suspended !== null) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't @@ -1107,7 +1106,7 @@ function completeWork( const newThennables = suspended.updateQueue; if (newThennables !== null) { workInProgress.updateQueue = newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } cutOffTailIfNeeded(renderState, true); @@ -1132,7 +1131,7 @@ function completeWork( // We have now passed our CPU deadline and we'll just give up further // attempts to render the main content and only render fallbacks. // The assumption is that this is usually faster. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; cutOffTailIfNeeded(renderState, false); @@ -1285,7 +1284,7 @@ function completeWork( prevIsHidden !== nextIsHidden && newProps.mode !== 'unstable-defer-without-hiding' ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } return null; diff --git a/packages/react-reconciler/src/ReactFiberCompleteWork.old.js b/packages/react-reconciler/src/ReactFiberCompleteWork.old.js index b85395337eed3..def3dda0940a7 100644 --- a/packages/react-reconciler/src/ReactFiberCompleteWork.old.js +++ b/packages/react-reconciler/src/ReactFiberCompleteWork.old.js @@ -59,13 +59,7 @@ import { LegacyHiddenComponent, } from './ReactWorkTags'; import {NoMode, BlockingMode, ProfileMode} from './ReactTypeOfMode'; -import { - Ref, - Update, - NoEffect, - DidCapture, - Snapshot, -} from './ReactSideEffectTags'; +import {Ref, Update, NoEffect, DidCapture, Snapshot} from './ReactFiberFlags'; import invariant from 'shared/invariant'; import { @@ -146,11 +140,11 @@ import {transferActualDuration} from './ReactProfilerTimer.old'; function markUpdate(workInProgress: Fiber) { // Tag the fiber with an update effect. This turns a Placement into // a PlacementAndUpdate. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } function markRef(workInProgress: Fiber) { - workInProgress.effectTag |= Ref; + workInProgress.flags |= Ref; } let appendAllChildren; @@ -297,7 +291,7 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - if ((node.effectTag & Update) !== NoEffect) { + if ((node.flags & Update) !== NoEffect) { // Need to toggle the visibility of the primary children. const newIsHidden = node.memoizedState !== null; if (newIsHidden) { @@ -391,7 +385,7 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - if ((node.effectTag & Update) !== NoEffect) { + if ((node.flags & Update) !== NoEffect) { // Need to toggle the visibility of the primary children. const newIsHidden = node.memoizedState !== null; if (newIsHidden) { @@ -696,7 +690,7 @@ function completeWork( // This handles the case of React rendering into a container with previous children. // It's also safe to do for updates too, because current.child would only be null // if the previous render was null (so the the container would already be empty). - workInProgress.effectTag |= Snapshot; + workInProgress.flags |= Snapshot; } } updateHostContainer(workInProgress); @@ -842,7 +836,7 @@ function completeWork( // However, in some of those paths, we might have reentered a hydration state // and then we might be inside a hydration state. In that case, we'll need to exit out of it. resetHydrationState(); - if ((workInProgress.effectTag & DidCapture) === NoEffect) { + if ((workInProgress.flags & DidCapture) === NoEffect) { // This boundary did not suspend so it's now hydrated and unsuspended. workInProgress.memoizedState = null; } @@ -851,13 +845,13 @@ function completeWork( // It's also a signal to replay events and the suspense callback. // If something suspended, schedule an effect to attach retry listeners. // So we might as well always mark this. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; return null; } } } - if ((workInProgress.effectTag & DidCapture) !== NoEffect) { + if ((workInProgress.flags & DidCapture) !== NoEffect) { // Something suspended. Re-render with the fallback children. workInProgress.lanes = renderLanes; // Do not reset the effect list. @@ -922,7 +916,7 @@ function completeWork( // If this boundary just timed out, schedule an effect to attach a // retry listener to the promise. This flag is also used to hide the // primary children. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if (supportsMutation) { @@ -933,7 +927,7 @@ function completeWork( // primary children. In mutation mode, we also need the flag to // *unhide* children that were previously hidden, so check if this // is currently timed out, too. - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } if ( @@ -942,7 +936,7 @@ function completeWork( workInProgress.memoizedProps.suspenseCallback != null ) { // Always notify the callback - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } return null; } @@ -978,8 +972,7 @@ function completeWork( return null; } - let didSuspendAlready = - (workInProgress.effectTag & DidCapture) !== NoEffect; + let didSuspendAlready = (workInProgress.flags & DidCapture) !== NoEffect; const renderedTail = renderState.rendering; if (renderedTail === null) { @@ -998,14 +991,14 @@ function completeWork( // findFirstSuspended. const cannotBeSuspended = renderHasNotSuspendedYet() && - (current === null || (current.effectTag & DidCapture) === NoEffect); + (current === null || (current.flags & DidCapture) === NoEffect); if (!cannotBeSuspended) { let row = workInProgress.child; while (row !== null) { const suspended = findFirstSuspended(row); if (suspended !== null) { didSuspendAlready = true; - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; cutOffTailIfNeeded(renderState, false); // If this is a newly suspended tree, it might not get committed as @@ -1023,7 +1016,7 @@ function completeWork( const newThennables = suspended.updateQueue; if (newThennables !== null) { workInProgress.updateQueue = newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } // Rerender the whole list, but this time, we'll force fallbacks @@ -1055,7 +1048,7 @@ function completeWork( // We have already passed our CPU deadline but we still have rows // left in the tail. We'll just give up further attempts to render // the main content and only render fallbacks. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; cutOffTailIfNeeded(renderState, false); @@ -1082,7 +1075,7 @@ function completeWork( if (!didSuspendAlready) { const suspended = findFirstSuspended(renderedTail); if (suspended !== null) { - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; // Ensure we transfer the update queue to the parent so that it doesn't @@ -1090,7 +1083,7 @@ function completeWork( const newThennables = suspended.updateQueue; if (newThennables !== null) { workInProgress.updateQueue = newThennables; - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } cutOffTailIfNeeded(renderState, true); @@ -1124,7 +1117,7 @@ function completeWork( // We have now passed our CPU deadline and we'll just give up further // attempts to render the main content and only render fallbacks. // The assumption is that this is usually faster. - workInProgress.effectTag |= DidCapture; + workInProgress.flags |= DidCapture; didSuspendAlready = true; cutOffTailIfNeeded(renderState, false); @@ -1281,7 +1274,7 @@ function completeWork( prevIsHidden !== nextIsHidden && newProps.mode !== 'unstable-defer-without-hiding' ) { - workInProgress.effectTag |= Update; + workInProgress.flags |= Update; } } return null; diff --git a/packages/react-reconciler/src/ReactFiberDevToolsHook.new.js b/packages/react-reconciler/src/ReactFiberDevToolsHook.new.js index 9664424c1f0d0..7df87ffbf764f 100644 --- a/packages/react-reconciler/src/ReactFiberDevToolsHook.new.js +++ b/packages/react-reconciler/src/ReactFiberDevToolsHook.new.js @@ -12,7 +12,7 @@ import {enableProfilerTimer} from 'shared/ReactFeatureFlags'; import type {Fiber, FiberRoot, ReactPriorityLevel} from './ReactInternalTypes'; import type {ReactNodeList} from 'shared/ReactTypes'; -import {DidCapture} from './ReactSideEffectTags'; +import {DidCapture} from './ReactFiberFlags'; declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: Object | void; @@ -84,7 +84,7 @@ export function onCommitRoot( ) { if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') { try { - const didError = (root.current.effectTag & DidCapture) === DidCapture; + const didError = (root.current.flags & DidCapture) === DidCapture; if (enableProfilerTimer) { injectedHook.onCommitFiberRoot( rendererID, diff --git a/packages/react-reconciler/src/ReactFiberDevToolsHook.old.js b/packages/react-reconciler/src/ReactFiberDevToolsHook.old.js index 9664424c1f0d0..7df87ffbf764f 100644 --- a/packages/react-reconciler/src/ReactFiberDevToolsHook.old.js +++ b/packages/react-reconciler/src/ReactFiberDevToolsHook.old.js @@ -12,7 +12,7 @@ import {enableProfilerTimer} from 'shared/ReactFeatureFlags'; import type {Fiber, FiberRoot, ReactPriorityLevel} from './ReactInternalTypes'; import type {ReactNodeList} from 'shared/ReactTypes'; -import {DidCapture} from './ReactSideEffectTags'; +import {DidCapture} from './ReactFiberFlags'; declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: Object | void; @@ -84,7 +84,7 @@ export function onCommitRoot( ) { if (injectedHook && typeof injectedHook.onCommitFiberRoot === 'function') { try { - const didError = (root.current.effectTag & DidCapture) === DidCapture; + const didError = (root.current.flags & DidCapture) === DidCapture; if (enableProfilerTimer) { injectedHook.onCommitFiberRoot( rendererID, diff --git a/packages/react-reconciler/src/ReactSideEffectTags.js b/packages/react-reconciler/src/ReactFiberFlags.js similarity index 96% rename from packages/react-reconciler/src/ReactSideEffectTags.js rename to packages/react-reconciler/src/ReactFiberFlags.js index 7a1aaf5bea77c..ed94246261a0d 100644 --- a/packages/react-reconciler/src/ReactSideEffectTags.js +++ b/packages/react-reconciler/src/ReactFiberFlags.js @@ -7,7 +7,7 @@ * @flow */ -export type SideEffectTag = number; +export type Flags = number; // Don't change these two values. They're used by React Dev Tools. export const NoEffect = /* */ 0b0000000000000000; @@ -47,7 +47,7 @@ export const ForceUpdateForLegacySuspense = /* */ 0b0100000000000000; // and instead rely on the static flag as a signal that there may be cleanup work. export const PassiveStatic = /* */ 0b1000000000000000; -// Union of side effect groupings as pertains to subtreeTag +// Union of side effect groupings as pertains to subtreeFlags export const BeforeMutationMask = /* */ 0b0000001100001010; export const MutationMask = /* */ 0b0000010010011110; export const LayoutMask = /* */ 0b0000000010100100; diff --git a/packages/react-reconciler/src/ReactFiberHooks.new.js b/packages/react-reconciler/src/ReactFiberHooks.new.js index 11de90dffa4e3..ab7b58715a554 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.new.js +++ b/packages/react-reconciler/src/ReactFiberHooks.new.js @@ -15,7 +15,7 @@ import type { } from 'shared/ReactTypes'; import type {Fiber, Dispatcher} from './ReactInternalTypes'; import type {Lanes, Lane} from './ReactFiberLane'; -import type {HookEffectTag} from './ReactHookEffectTags'; +import type {HookFlags} from './ReactHookEffectTags'; import type {ReactPriorityLevel} from './ReactInternalTypes'; import type {FiberRoot} from './ReactInternalTypes'; import type {OpaqueIDType} from './ReactFiberHostConfig'; @@ -48,7 +48,7 @@ import { Update as UpdateEffect, Passive as PassiveEffect, PassiveStatic as PassiveStaticEffect, -} from './ReactSideEffectTags'; +} from './ReactFiberFlags'; import { HasEffect as HookHasEffect, Layout as HookLayout, @@ -141,7 +141,7 @@ export type Hook = {| |}; export type Effect = {| - tag: HookEffectTag, + tag: HookFlags, create: () => (() => void) | void, destroy: (() => void) | void, deps: Array | null, @@ -482,7 +482,7 @@ export function bailoutHooks( lanes: Lanes, ) { workInProgress.updateQueue = current.updateQueue; - workInProgress.effectTag &= ~(PassiveEffect | UpdateEffect); + workInProgress.flags &= ~(PassiveEffect | UpdateEffect); current.lanes = removeLanes(current.lanes, lanes); } @@ -1191,19 +1191,19 @@ function updateRef(initialValue: T): {|current: T|} { return hook.memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps): void { +function mountEffectImpl(fiberFlags, hookFlags, create, deps): void { const hook = mountWorkInProgressHook(); const nextDeps = deps === undefined ? null : deps; - currentlyRenderingFiber.effectTag |= fiberEffectTag; + currentlyRenderingFiber.flags |= fiberFlags; hook.memoizedState = pushEffect( - HookHasEffect | hookEffectTag, + HookHasEffect | hookFlags, create, undefined, nextDeps, ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps): void { +function updateEffectImpl(fiberFlags, hookFlags, create, deps): void { const hook = updateWorkInProgressHook(); const nextDeps = deps === undefined ? null : deps; let destroy = undefined; @@ -1214,16 +1214,16 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps): void { if (nextDeps !== null) { const prevDeps = prevEffect.deps; if (areHookInputsEqual(nextDeps, prevDeps)) { - pushEffect(hookEffectTag, create, destroy, nextDeps); + pushEffect(hookFlags, create, destroy, nextDeps); return; } } } - currentlyRenderingFiber.effectTag |= fiberEffectTag; + currentlyRenderingFiber.flags |= fiberFlags; hook.memoizedState = pushEffect( - HookHasEffect | hookEffectTag, + HookHasEffect | hookFlags, create, destroy, nextDeps, @@ -1615,7 +1615,7 @@ function mountOpaqueIdentifier(): OpaqueIDType | void { const setId = mountState(id)[1]; if ((currentlyRenderingFiber.mode & BlockingMode) === NoMode) { - currentlyRenderingFiber.effectTag |= + currentlyRenderingFiber.flags |= UpdateEffect | PassiveEffect | PassiveStaticEffect; pushEffect( HookHasEffect | HookPassive, diff --git a/packages/react-reconciler/src/ReactFiberHooks.old.js b/packages/react-reconciler/src/ReactFiberHooks.old.js index 0e4d4591d705d..972a746402786 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.old.js +++ b/packages/react-reconciler/src/ReactFiberHooks.old.js @@ -15,7 +15,7 @@ import type { } from 'shared/ReactTypes'; import type {Fiber, Dispatcher} from './ReactInternalTypes'; import type {Lanes, Lane} from './ReactFiberLane'; -import type {HookEffectTag} from './ReactHookEffectTags'; +import type {HookFlags} from './ReactHookEffectTags'; import type {ReactPriorityLevel} from './ReactInternalTypes'; import type {FiberRoot} from './ReactInternalTypes'; import type {OpaqueIDType} from './ReactFiberHostConfig'; @@ -47,7 +47,7 @@ import {readContext} from './ReactFiberNewContext.old'; import { Update as UpdateEffect, Passive as PassiveEffect, -} from './ReactSideEffectTags'; +} from './ReactFiberFlags'; import { HasEffect as HookHasEffect, Layout as HookLayout, @@ -140,7 +140,7 @@ export type Hook = {| |}; export type Effect = {| - tag: HookEffectTag, + tag: HookFlags, create: () => (() => void) | void, destroy: (() => void) | void, deps: Array | null, @@ -481,7 +481,7 @@ export function bailoutHooks( lanes: Lanes, ) { workInProgress.updateQueue = current.updateQueue; - workInProgress.effectTag &= ~(PassiveEffect | UpdateEffect); + workInProgress.flags &= ~(PassiveEffect | UpdateEffect); current.lanes = removeLanes(current.lanes, lanes); } @@ -1190,19 +1190,19 @@ function updateRef(initialValue: T): {|current: T|} { return hook.memoizedState; } -function mountEffectImpl(fiberEffectTag, hookEffectTag, create, deps): void { +function mountEffectImpl(fiberFlags, hookFlags, create, deps): void { const hook = mountWorkInProgressHook(); const nextDeps = deps === undefined ? null : deps; - currentlyRenderingFiber.effectTag |= fiberEffectTag; + currentlyRenderingFiber.flags |= fiberFlags; hook.memoizedState = pushEffect( - HookHasEffect | hookEffectTag, + HookHasEffect | hookFlags, create, undefined, nextDeps, ); } -function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps): void { +function updateEffectImpl(fiberFlags, hookFlags, create, deps): void { const hook = updateWorkInProgressHook(); const nextDeps = deps === undefined ? null : deps; let destroy = undefined; @@ -1213,16 +1213,16 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps): void { if (nextDeps !== null) { const prevDeps = prevEffect.deps; if (areHookInputsEqual(nextDeps, prevDeps)) { - pushEffect(hookEffectTag, create, destroy, nextDeps); + pushEffect(hookFlags, create, destroy, nextDeps); return; } } } - currentlyRenderingFiber.effectTag |= fiberEffectTag; + currentlyRenderingFiber.flags |= fiberFlags; hook.memoizedState = pushEffect( - HookHasEffect | hookEffectTag, + HookHasEffect | hookFlags, create, destroy, nextDeps, @@ -1614,7 +1614,7 @@ function mountOpaqueIdentifier(): OpaqueIDType | void { const setId = mountState(id)[1]; if ((currentlyRenderingFiber.mode & BlockingMode) === NoMode) { - currentlyRenderingFiber.effectTag |= UpdateEffect | PassiveEffect; + currentlyRenderingFiber.flags |= UpdateEffect | PassiveEffect; pushEffect( HookHasEffect | HookPassive, () => { diff --git a/packages/react-reconciler/src/ReactFiberHydrationContext.new.js b/packages/react-reconciler/src/ReactFiberHydrationContext.new.js index 5baf0c059037a..da5e5cbfaa456 100644 --- a/packages/react-reconciler/src/ReactFiberHydrationContext.new.js +++ b/packages/react-reconciler/src/ReactFiberHydrationContext.new.js @@ -24,7 +24,7 @@ import { HostRoot, SuspenseComponent, } from './ReactWorkTags'; -import {Deletion, Hydrating, Placement} from './ReactSideEffectTags'; +import {Deletion, Hydrating, Placement} from './ReactFiberFlags'; import invariant from 'shared/invariant'; import { @@ -129,14 +129,14 @@ function deleteHydratableInstance( if (deletions === null) { returnFiber.deletions = [childToDelete]; // TODO (effects) Rename this to better reflect its new usage (e.g. ChildDeletions) - returnFiber.effectTag |= Deletion; + returnFiber.flags |= Deletion; } else { deletions.push(childToDelete); } } function insertNonHydratedInstance(returnFiber: Fiber, fiber: Fiber) { - fiber.effectTag = (fiber.effectTag & ~Hydrating) | Placement; + fiber.flags = (fiber.flags & ~Hydrating) | Placement; if (__DEV__) { switch (returnFiber.tag) { case HostRoot: { diff --git a/packages/react-reconciler/src/ReactFiberHydrationContext.old.js b/packages/react-reconciler/src/ReactFiberHydrationContext.old.js index 60f8df3d01562..7576bd5ac0811 100644 --- a/packages/react-reconciler/src/ReactFiberHydrationContext.old.js +++ b/packages/react-reconciler/src/ReactFiberHydrationContext.old.js @@ -24,7 +24,7 @@ import { HostRoot, SuspenseComponent, } from './ReactWorkTags'; -import {Deletion, Placement, Hydrating} from './ReactSideEffectTags'; +import {Deletion, Placement, Hydrating} from './ReactFiberFlags'; import invariant from 'shared/invariant'; import { @@ -124,7 +124,7 @@ function deleteHydratableInstance( const childToDelete = createFiberFromHostInstanceForDeletion(); childToDelete.stateNode = instance; childToDelete.return = returnFiber; - childToDelete.effectTag = Deletion; + childToDelete.flags = Deletion; // This might seem like it belongs on progressedFirstDeletion. However, // these children are not part of the reconciliation list of children. @@ -140,7 +140,7 @@ function deleteHydratableInstance( } function insertNonHydratedInstance(returnFiber: Fiber, fiber: Fiber) { - fiber.effectTag = (fiber.effectTag & ~Hydrating) | Placement; + fiber.flags = (fiber.flags & ~Hydrating) | Placement; if (__DEV__) { switch (returnFiber.tag) { case HostRoot: { diff --git a/packages/react-reconciler/src/ReactFiberSuspenseComponent.new.js b/packages/react-reconciler/src/ReactFiberSuspenseComponent.new.js index ce49b80419fca..e64722201353f 100644 --- a/packages/react-reconciler/src/ReactFiberSuspenseComponent.new.js +++ b/packages/react-reconciler/src/ReactFiberSuspenseComponent.new.js @@ -11,7 +11,7 @@ import type {Fiber} from './ReactInternalTypes'; import type {SuspenseInstance} from './ReactFiberHostConfig'; import type {Lane} from './ReactFiberLane'; import {SuspenseComponent, SuspenseListComponent} from './ReactWorkTags'; -import {NoEffect, DidCapture} from './ReactSideEffectTags'; +import {NoEffect, DidCapture} from './ReactFiberFlags'; import { isSuspenseInstancePending, isSuspenseInstanceFallback, @@ -104,7 +104,7 @@ export function findFirstSuspended(row: Fiber): null | Fiber { // keep track of whether it suspended or not. node.memoizedProps.revealOrder !== undefined ) { - const didSuspend = (node.effectTag & DidCapture) !== NoEffect; + const didSuspend = (node.flags & DidCapture) !== NoEffect; if (didSuspend) { return node; } diff --git a/packages/react-reconciler/src/ReactFiberSuspenseComponent.old.js b/packages/react-reconciler/src/ReactFiberSuspenseComponent.old.js index 49e586c232327..cbe59df0c5c2e 100644 --- a/packages/react-reconciler/src/ReactFiberSuspenseComponent.old.js +++ b/packages/react-reconciler/src/ReactFiberSuspenseComponent.old.js @@ -11,7 +11,7 @@ import type {Fiber} from './ReactInternalTypes'; import type {SuspenseInstance} from './ReactFiberHostConfig'; import type {Lane} from './ReactFiberLane'; import {SuspenseComponent, SuspenseListComponent} from './ReactWorkTags'; -import {NoEffect, DidCapture} from './ReactSideEffectTags'; +import {NoEffect, DidCapture} from './ReactFiberFlags'; import { isSuspenseInstancePending, isSuspenseInstanceFallback, @@ -107,7 +107,7 @@ export function findFirstSuspended(row: Fiber): null | Fiber { // keep track of whether it suspended or not. node.memoizedProps.revealOrder !== undefined ) { - const didSuspend = (node.effectTag & DidCapture) !== NoEffect; + const didSuspend = (node.flags & DidCapture) !== NoEffect; if (didSuspend) { return node; } diff --git a/packages/react-reconciler/src/ReactFiberThrow.new.js b/packages/react-reconciler/src/ReactFiberThrow.new.js index 1e1ca2633c924..737c7982b931a 100644 --- a/packages/react-reconciler/src/ReactFiberThrow.new.js +++ b/packages/react-reconciler/src/ReactFiberThrow.new.js @@ -29,7 +29,7 @@ import { ShouldCapture, LifecycleEffectMask, ForceUpdateForLegacySuspense, -} from './ReactSideEffectTags'; +} from './ReactFiberFlags'; import {shouldCaptureSuspense} from './ReactFiberSuspenseComponent.new'; import {NoMode, BlockingMode, DebugTracingMode} from './ReactTypeOfMode'; import { @@ -184,7 +184,7 @@ function throwException( rootRenderLanes: Lanes, ) { // The source fiber did not complete. - sourceFiber.effectTag |= Incomplete; + sourceFiber.flags |= Incomplete; if ( value !== null && @@ -255,13 +255,13 @@ function throwException( // inside a blocking mode tree. If the Suspense is outside of it, we // should *not* suspend the commit. if ((workInProgress.mode & BlockingMode) === NoMode) { - workInProgress.effectTag |= DidCapture; - sourceFiber.effectTag |= ForceUpdateForLegacySuspense; + workInProgress.flags |= DidCapture; + sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. // But we shouldn't call any lifecycle methods or callbacks. Remove // all lifecycle effect tags. - sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete); + sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); if (sourceFiber.tag === ClassComponent) { const currentSourceFiber = sourceFiber.alternate; @@ -332,7 +332,7 @@ function throwException( attachPingListener(root, wakeable, rootRenderLanes); - workInProgress.effectTag |= ShouldCapture; + workInProgress.flags |= ShouldCapture; workInProgress.lanes = rootRenderLanes; return; @@ -363,7 +363,7 @@ function throwException( switch (workInProgress.tag) { case HostRoot: { const errorInfo = value; - workInProgress.effectTag |= ShouldCapture; + workInProgress.flags |= ShouldCapture; const lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); const update = createRootErrorUpdate(workInProgress, errorInfo, lane); @@ -376,13 +376,13 @@ function throwException( const ctor = workInProgress.type; const instance = workInProgress.stateNode; if ( - (workInProgress.effectTag & DidCapture) === NoEffect && + (workInProgress.flags & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || (instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) ) { - workInProgress.effectTag |= ShouldCapture; + workInProgress.flags |= ShouldCapture; const lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state diff --git a/packages/react-reconciler/src/ReactFiberThrow.old.js b/packages/react-reconciler/src/ReactFiberThrow.old.js index 5f37bbb059b74..b725e6419ca28 100644 --- a/packages/react-reconciler/src/ReactFiberThrow.old.js +++ b/packages/react-reconciler/src/ReactFiberThrow.old.js @@ -29,7 +29,7 @@ import { ShouldCapture, LifecycleEffectMask, ForceUpdateForLegacySuspense, -} from './ReactSideEffectTags'; +} from './ReactFiberFlags'; import {shouldCaptureSuspense} from './ReactFiberSuspenseComponent.old'; import {NoMode, BlockingMode, DebugTracingMode} from './ReactTypeOfMode'; import { @@ -184,7 +184,7 @@ function throwException( rootRenderLanes: Lanes, ) { // The source fiber did not complete. - sourceFiber.effectTag |= Incomplete; + sourceFiber.flags |= Incomplete; // Its effect list is no longer valid. sourceFiber.firstEffect = sourceFiber.lastEffect = null; @@ -257,13 +257,13 @@ function throwException( // inside a blocking mode tree. If the Suspense is outside of it, we // should *not* suspend the commit. if ((workInProgress.mode & BlockingMode) === NoMode) { - workInProgress.effectTag |= DidCapture; - sourceFiber.effectTag |= ForceUpdateForLegacySuspense; + workInProgress.flags |= DidCapture; + sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. // But we shouldn't call any lifecycle methods or callbacks. Remove // all lifecycle effect tags. - sourceFiber.effectTag &= ~(LifecycleEffectMask | Incomplete); + sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); if (sourceFiber.tag === ClassComponent) { const currentSourceFiber = sourceFiber.alternate; @@ -334,7 +334,7 @@ function throwException( attachPingListener(root, wakeable, rootRenderLanes); - workInProgress.effectTag |= ShouldCapture; + workInProgress.flags |= ShouldCapture; workInProgress.lanes = rootRenderLanes; return; @@ -365,7 +365,7 @@ function throwException( switch (workInProgress.tag) { case HostRoot: { const errorInfo = value; - workInProgress.effectTag |= ShouldCapture; + workInProgress.flags |= ShouldCapture; const lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); const update = createRootErrorUpdate(workInProgress, errorInfo, lane); @@ -378,13 +378,13 @@ function throwException( const ctor = workInProgress.type; const instance = workInProgress.stateNode; if ( - (workInProgress.effectTag & DidCapture) === NoEffect && + (workInProgress.flags & DidCapture) === NoEffect && (typeof ctor.getDerivedStateFromError === 'function' || (instance !== null && typeof instance.componentDidCatch === 'function' && !isAlreadyFailedLegacyErrorBoundary(instance))) ) { - workInProgress.effectTag |= ShouldCapture; + workInProgress.flags |= ShouldCapture; const lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state diff --git a/packages/react-reconciler/src/ReactFiberTreeReflection.js b/packages/react-reconciler/src/ReactFiberTreeReflection.js index ed63a099f4279..e7df8b7fd46cd 100644 --- a/packages/react-reconciler/src/ReactFiberTreeReflection.js +++ b/packages/react-reconciler/src/ReactFiberTreeReflection.js @@ -25,7 +25,7 @@ import { FundamentalComponent, SuspenseComponent, } from './ReactWorkTags'; -import {NoEffect, Placement, Hydrating} from './ReactSideEffectTags'; +import {NoEffect, Placement, Hydrating} from './ReactFiberFlags'; import {enableFundamentalAPI} from 'shared/ReactFeatureFlags'; const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; @@ -39,7 +39,7 @@ export function getNearestMountedFiber(fiber: Fiber): null | Fiber { let nextNode = node; do { node = nextNode; - if ((node.effectTag & (Placement | Hydrating)) !== NoEffect) { + if ((node.flags & (Placement | Hydrating)) !== NoEffect) { // This is an insertion or in-progress hydration. The nearest possible // mounted fiber is the parent but we need to continue to figure out // if that one is still mounted. diff --git a/packages/react-reconciler/src/ReactFiberUnwindWork.new.js b/packages/react-reconciler/src/ReactFiberUnwindWork.new.js index 540ba6ef2aba0..37c6fb6f65ef0 100644 --- a/packages/react-reconciler/src/ReactFiberUnwindWork.new.js +++ b/packages/react-reconciler/src/ReactFiberUnwindWork.new.js @@ -23,7 +23,7 @@ import { OffscreenComponent, LegacyHiddenComponent, } from './ReactWorkTags'; -import {DidCapture, NoEffect, ShouldCapture} from './ReactSideEffectTags'; +import {DidCapture, NoEffect, ShouldCapture} from './ReactFiberFlags'; import {NoMode, ProfileMode} from './ReactTypeOfMode'; import { enableSuspenseServerRenderer, @@ -51,9 +51,9 @@ function unwindWork(workInProgress: Fiber, renderLanes: Lanes) { if (isLegacyContextProvider(Component)) { popLegacyContext(workInProgress); } - const effectTag = workInProgress.effectTag; - if (effectTag & ShouldCapture) { - workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; + const flags = workInProgress.flags; + if (flags & ShouldCapture) { + workInProgress.flags = (flags & ~ShouldCapture) | DidCapture; if ( enableProfilerTimer && (workInProgress.mode & ProfileMode) !== NoMode @@ -68,13 +68,13 @@ function unwindWork(workInProgress: Fiber, renderLanes: Lanes) { popHostContainer(workInProgress); popTopLevelLegacyContextObject(workInProgress); resetMutableSourceWorkInProgressVersions(); - const effectTag = workInProgress.effectTag; + const flags = workInProgress.flags; invariant( - (effectTag & DidCapture) === NoEffect, + (flags & DidCapture) === NoEffect, 'The root failed to unmount after an error. This is likely a bug in ' + 'React. Please file an issue.', ); - workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = (flags & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { @@ -96,9 +96,9 @@ function unwindWork(workInProgress: Fiber, renderLanes: Lanes) { resetHydrationState(); } } - const effectTag = workInProgress.effectTag; - if (effectTag & ShouldCapture) { - workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; + const flags = workInProgress.flags; + if (flags & ShouldCapture) { + workInProgress.flags = (flags & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. if ( enableProfilerTimer && diff --git a/packages/react-reconciler/src/ReactFiberUnwindWork.old.js b/packages/react-reconciler/src/ReactFiberUnwindWork.old.js index 41d5519d895a2..1c857aec73879 100644 --- a/packages/react-reconciler/src/ReactFiberUnwindWork.old.js +++ b/packages/react-reconciler/src/ReactFiberUnwindWork.old.js @@ -23,7 +23,7 @@ import { OffscreenComponent, LegacyHiddenComponent, } from './ReactWorkTags'; -import {DidCapture, NoEffect, ShouldCapture} from './ReactSideEffectTags'; +import {DidCapture, NoEffect, ShouldCapture} from './ReactFiberFlags'; import {NoMode, ProfileMode} from './ReactTypeOfMode'; import { enableSuspenseServerRenderer, @@ -51,9 +51,9 @@ function unwindWork(workInProgress: Fiber, renderLanes: Lanes) { if (isLegacyContextProvider(Component)) { popLegacyContext(workInProgress); } - const effectTag = workInProgress.effectTag; - if (effectTag & ShouldCapture) { - workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; + const flags = workInProgress.flags; + if (flags & ShouldCapture) { + workInProgress.flags = (flags & ~ShouldCapture) | DidCapture; if ( enableProfilerTimer && (workInProgress.mode & ProfileMode) !== NoMode @@ -68,13 +68,13 @@ function unwindWork(workInProgress: Fiber, renderLanes: Lanes) { popHostContainer(workInProgress); popTopLevelLegacyContextObject(workInProgress); resetMutableSourceWorkInProgressVersions(); - const effectTag = workInProgress.effectTag; + const flags = workInProgress.flags; invariant( - (effectTag & DidCapture) === NoEffect, + (flags & DidCapture) === NoEffect, 'The root failed to unmount after an error. This is likely a bug in ' + 'React. Please file an issue.', ); - workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = (flags & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { @@ -96,9 +96,9 @@ function unwindWork(workInProgress: Fiber, renderLanes: Lanes) { resetHydrationState(); } } - const effectTag = workInProgress.effectTag; - if (effectTag & ShouldCapture) { - workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; + const flags = workInProgress.flags; + if (flags & ShouldCapture) { + workInProgress.flags = (flags & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. if ( enableProfilerTimer && diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js index c2dc019d0234b..660efa7a8db66 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js @@ -139,15 +139,15 @@ import { MutationMask, LayoutMask, PassiveMask, -} from './ReactSideEffectTags'; +} from './ReactFiberFlags'; import { - NoEffect as NoSubtreeTag, - BeforeMutation as BeforeMutationSubtreeTag, - Mutation as MutationSubtreeTag, - Layout as LayoutSubtreeTag, - Passive as PassiveSubtreeTag, - PassiveStatic as PassiveStaticSubtreeTag, -} from './ReactSubtreeTags'; + NoEffect as NoSubtreeFlags, + BeforeMutation as BeforeMutationSubtreeFlags, + Mutation as MutationSubtreeFlags, + Layout as LayoutSubtreeFlags, + Passive as PassiveSubtreeFlags, + PassiveStatic as PassiveStaticSubtreeFlags, +} from './ReactSubtreeFlags'; import { NoLanePriority, SyncLanePriority, @@ -649,7 +649,7 @@ function markUpdateLaneFromFiberToRoot( if (__DEV__) { if ( alternate === null && - (sourceFiber.effectTag & (Placement | Hydrating)) !== NoEffect + (sourceFiber.flags & (Placement | Hydrating)) !== NoEffect ) { warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } @@ -664,7 +664,7 @@ function markUpdateLaneFromFiberToRoot( alternate.childLanes = mergeLanes(alternate.childLanes, lane); } else { if (__DEV__) { - if ((parent.effectTag & (Placement | Hydrating)) !== NoEffect) { + if ((parent.flags & (Placement | Hydrating)) !== NoEffect) { warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } } @@ -1705,7 +1705,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void { const returnFiber = completedWork.return; // Check if the work completed or if something threw. - if ((completedWork.effectTag & Incomplete) === NoEffect) { + if ((completedWork.flags & Incomplete) === NoEffect) { setCurrentDebugFiberInDEV(completedWork); let next; if ( @@ -1741,7 +1741,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void { // back here again. // Since we're restarting, remove anything that is not a host effect // from the effect tag. - next.effectTag &= HostEffectMask; + next.flags &= HostEffectMask; workInProgress = next; return; } @@ -1765,8 +1765,8 @@ function completeUnitOfWork(unitOfWork: Fiber): void { if (returnFiber !== null) { // Mark the parent fiber as incomplete - returnFiber.effectTag |= Incomplete; - returnFiber.subtreeTag = NoSubtreeTag; + returnFiber.flags |= Incomplete; + returnFiber.subtreeFlags = NoSubtreeFlags; returnFiber.deletions = null; } } @@ -1809,7 +1809,7 @@ function resetChildLanes(completedWork: Fiber) { completedWork.alternate.child === completedWork.child; let newChildLanes = NoLanes; - let subtreeTag = NoSubtreeTag; + let subtreeFlags = NoSubtreeFlags; if (!didBailout) { // Bubble up the earliest expiration time. @@ -1826,23 +1826,23 @@ function resetChildLanes(completedWork: Fiber) { mergeLanes(child.lanes, child.childLanes), ); - subtreeTag |= child.subtreeTag; + subtreeFlags |= child.subtreeFlags; - const effectTag = child.effectTag; - if ((effectTag & BeforeMutationMask) !== NoEffect) { - subtreeTag |= BeforeMutationSubtreeTag; + const flags = child.flags; + if ((flags & BeforeMutationMask) !== NoEffect) { + subtreeFlags |= BeforeMutationSubtreeFlags; } - if ((effectTag & MutationMask) !== NoEffect) { - subtreeTag |= MutationSubtreeTag; + if ((flags & MutationMask) !== NoEffect) { + subtreeFlags |= MutationSubtreeFlags; } - if ((effectTag & LayoutMask) !== NoEffect) { - subtreeTag |= LayoutSubtreeTag; + if ((flags & LayoutMask) !== NoEffect) { + subtreeFlags |= LayoutSubtreeFlags; } - if ((effectTag & PassiveMask) !== NoEffect) { - subtreeTag |= PassiveSubtreeTag; + if ((flags & PassiveMask) !== NoEffect) { + subtreeFlags |= PassiveSubtreeFlags; } - if ((effectTag & PassiveStatic) !== NoEffect) { - subtreeTag |= PassiveStaticSubtreeTag; + if ((flags & PassiveStatic) !== NoEffect) { + subtreeFlags |= PassiveStaticSubtreeFlags; } // When a fiber is cloned, its actualDuration is reset to 0. This value will @@ -1879,30 +1879,30 @@ function resetChildLanes(completedWork: Fiber) { mergeLanes(child.lanes, child.childLanes), ); - subtreeTag |= child.subtreeTag; + subtreeFlags |= child.subtreeFlags; - const effectTag = child.effectTag; - if ((effectTag & BeforeMutationMask) !== NoEffect) { - subtreeTag |= BeforeMutationSubtreeTag; + const flags = child.flags; + if ((flags & BeforeMutationMask) !== NoEffect) { + subtreeFlags |= BeforeMutationSubtreeFlags; } - if ((effectTag & MutationMask) !== NoEffect) { - subtreeTag |= MutationSubtreeTag; + if ((flags & MutationMask) !== NoEffect) { + subtreeFlags |= MutationSubtreeFlags; } - if ((effectTag & LayoutMask) !== NoEffect) { - subtreeTag |= LayoutSubtreeTag; + if ((flags & LayoutMask) !== NoEffect) { + subtreeFlags |= LayoutSubtreeFlags; } - if ((effectTag & PassiveMask) !== NoEffect) { - subtreeTag |= PassiveSubtreeTag; + if ((flags & PassiveMask) !== NoEffect) { + subtreeFlags |= PassiveSubtreeFlags; } - if ((effectTag & PassiveStatic) !== NoEffect) { - subtreeTag |= PassiveStaticSubtreeTag; + if ((flags & PassiveStatic) !== NoEffect) { + subtreeFlags |= PassiveStaticSubtreeFlags; } child = child.sibling; } } - completedWork.subtreeTag |= subtreeTag; + completedWork.subtreeFlags |= subtreeFlags; } else { // Bubble up the earliest expiration time. if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoMode) { @@ -1919,10 +1919,10 @@ function resetChildLanes(completedWork: Fiber) { // Preserve passive static flag even in the case of a bailout; // otherwise a subsequent unmount may bailout before calling destroy functions. - subtreeTag |= child.subtreeTag & PassiveStaticSubtreeTag; - const effectTag = child.effectTag; - if ((effectTag & PassiveStatic) !== NoEffect) { - subtreeTag |= PassiveStaticSubtreeTag; + subtreeFlags |= child.subtreeFlags & PassiveStaticSubtreeFlags; + const flags = child.flags; + if ((flags & PassiveStatic) !== NoEffect) { + subtreeFlags |= PassiveStaticSubtreeFlags; } treeBaseDuration += child.treeBaseDuration; @@ -1951,17 +1951,17 @@ function resetChildLanes(completedWork: Fiber) { // Preserve passive static flag even in the case of a bailout; // otherwise a subsequent unmount may bailout before calling destroy functions. - subtreeTag |= child.subtreeTag & PassiveStaticSubtreeTag; - const effectTag = child.effectTag; - if ((effectTag & PassiveStatic) !== NoEffect) { - subtreeTag |= PassiveStaticSubtreeTag; + subtreeFlags |= child.subtreeFlags & PassiveStaticSubtreeFlags; + const flags = child.flags; + if ((flags & PassiveStatic) !== NoEffect) { + subtreeFlags |= PassiveStaticSubtreeFlags; } child = child.sibling; } } - completedWork.subtreeTag |= subtreeTag; + completedWork.subtreeFlags |= subtreeFlags; } completedWork.childLanes = newChildLanes; @@ -2066,14 +2066,14 @@ function commitRootImpl(root, renderPriorityLevel) { // only other reason this optimization exists is because it affects profiling. // Reconsider whether this is necessary. const subtreeHasEffects = - (finishedWork.subtreeTag & - (BeforeMutationSubtreeTag | - MutationSubtreeTag | - LayoutSubtreeTag | - PassiveSubtreeTag)) !== - NoSubtreeTag; + (finishedWork.subtreeFlags & + (BeforeMutationSubtreeFlags | + MutationSubtreeFlags | + LayoutSubtreeFlags | + PassiveSubtreeFlags)) !== + NoSubtreeFlags; const rootHasEffect = - (finishedWork.effectTag & + (finishedWork.flags & (BeforeMutationMask | MutationMask | LayoutMask | PassiveMask)) !== NoEffect; @@ -2152,8 +2152,8 @@ function commitRootImpl(root, renderPriorityLevel) { // If there are pending passive effects, schedule a callback to process them. if ( - (finishedWork.subtreeTag & PassiveSubtreeTag) !== NoSubtreeTag || - (finishedWork.effectTag & PassiveMask) !== NoEffect + (finishedWork.subtreeFlags & PassiveSubtreeFlags) !== NoSubtreeFlags || + (finishedWork.flags & PassiveMask) !== NoEffect ) { if (!rootDoesHavePassiveEffects) { rootDoesHavePassiveEffects = true; @@ -2306,8 +2306,9 @@ function commitBeforeMutationEffects(firstChild: Fiber) { } if (fiber.child !== null) { - const primarySubtreeTag = fiber.subtreeTag & BeforeMutationSubtreeTag; - if (primarySubtreeTag !== NoSubtreeTag) { + const primarySubtreeFlags = + fiber.subtreeFlags & BeforeMutationSubtreeFlags; + if (primarySubtreeFlags !== NoSubtreeFlags) { commitBeforeMutationEffects(fiber.child); } } @@ -2333,7 +2334,7 @@ function commitBeforeMutationEffects(firstChild: Fiber) { function commitBeforeMutationEffectsImpl(fiber: Fiber) { const current = fiber.alternate; - const effectTag = fiber.effectTag; + const flags = fiber.flags; if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { // Check to see if the focused element was inside of a hidden (Suspense) subtree. @@ -2348,13 +2349,13 @@ function commitBeforeMutationEffectsImpl(fiber: Fiber) { } } - if ((effectTag & Snapshot) !== NoEffect) { + if ((flags & Snapshot) !== NoEffect) { setCurrentDebugFiberInDEV(fiber); commitBeforeMutationEffectOnFiber(current, fiber); resetCurrentDebugFiberInDEV(); } - if ((effectTag & Passive) !== NoEffect) { + if ((flags & Passive) !== NoEffect) { // If there are passive effects, schedule a callback to flush at // the earliest opportunity. if (!rootDoesHavePassiveEffects) { @@ -2372,7 +2373,7 @@ function commitBeforeMutationEffectsDeletions(deletions: Array) { const fiber = deletions[i]; // TODO (effects) It would be nice to avoid calling doesFiberContain() - // Maybe we can repurpose one of the subtreeTag positions for this instead? + // Maybe we can repurpose one of the subtreeFlags positions for this instead? // Use it to store which part of the tree the focused instance is in? // This assumes we can safely determine that instance during the "render" phase. @@ -2401,8 +2402,8 @@ function commitMutationEffects( } if (fiber.child !== null) { - const primarySubtreeTag = fiber.subtreeTag & MutationSubtreeTag; - if (primarySubtreeTag !== NoSubtreeTag) { + const primarySubtreeFlags = fiber.subtreeFlags & MutationSubtreeFlags; + if (primarySubtreeFlags !== NoSubtreeFlags) { commitMutationEffects(fiber.child, root, renderPriorityLevel); } } @@ -2438,12 +2439,12 @@ function commitMutationEffectsImpl( root: FiberRoot, renderPriorityLevel, ) { - const effectTag = fiber.effectTag; - if (effectTag & ContentReset) { + const flags = fiber.flags; + if (flags & ContentReset) { commitResetTextContent(fiber); } - if (effectTag & Ref) { + if (flags & Ref) { const current = fiber.alternate; if (current !== null) { commitDetachRef(current); @@ -2461,15 +2462,15 @@ function commitMutationEffectsImpl( // updates, and deletions. To avoid needing to add a case for every possible // bitmap value, we remove the secondary effects from the effect tag and // switch on that value. - const primaryEffectTag = effectTag & (Placement | Update | Hydrating); - switch (primaryEffectTag) { + const primaryFlags = flags & (Placement | Update | Hydrating); + switch (primaryFlags) { case Placement: { commitPlacement(fiber); // Clear the "placement" from effect tag so that we know that this is // inserted, before any life-cycles like componentDidMount gets called. // TODO: findDOMNode doesn't rely on this any more but isMounted does // and isMounted is deprecated anyway so we should be able to kill this. - fiber.effectTag &= ~Placement; + fiber.flags &= ~Placement; break; } case PlacementAndUpdate: { @@ -2477,7 +2478,7 @@ function commitMutationEffectsImpl( commitPlacement(fiber); // Clear the "placement" from effect tag so that we know that this is // inserted, before any life-cycles like componentDidMount gets called. - fiber.effectTag &= ~Placement; + fiber.flags &= ~Placement; // Update const current = fiber.alternate; @@ -2485,11 +2486,11 @@ function commitMutationEffectsImpl( break; } case Hydrating: { - fiber.effectTag &= ~Hydrating; + fiber.flags &= ~Hydrating; break; } case HydratingAndUpdate: { - fiber.effectTag &= ~Hydrating; + fiber.flags &= ~Hydrating; // Update const current = fiber.alternate; @@ -2559,8 +2560,8 @@ function commitLayoutEffects( let fiber = firstChild; while (fiber !== null) { if (fiber.child !== null) { - const primarySubtreeTag = fiber.subtreeTag & LayoutSubtreeTag; - if (primarySubtreeTag !== NoSubtreeTag) { + const primarySubtreeFlags = fiber.subtreeFlags & LayoutSubtreeFlags; + if (primarySubtreeFlags !== NoSubtreeFlags) { commitLayoutEffects(fiber.child, root, committedLanes); } } @@ -2596,11 +2597,11 @@ function commitLayoutEffectsImpl( root: FiberRoot, committedLanes: Lanes, ) { - const effectTag = fiber.effectTag; + const flags = fiber.flags; setCurrentDebugFiberInDEV(fiber); - if (effectTag & (Update | Callback)) { + if (flags & (Update | Callback)) { const current = fiber.alternate; commitLayoutEffectOnFiber(root, current, fiber, committedLanes); } @@ -2608,11 +2609,11 @@ function commitLayoutEffectsImpl( if (enableScopeAPI) { // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. - if (effectTag & Ref && fiber.tag !== ScopeComponent) { + if (flags & Ref && fiber.tag !== ScopeComponent) { commitAttachRef(fiber); } } else { - if (effectTag & Ref) { + if (flags & Ref) { commitAttachRef(fiber); } } @@ -2661,13 +2662,13 @@ export function enqueuePendingPassiveProfilerEffect(fiber: Fiber): void { function flushPassiveMountEffects(firstChild: Fiber): void { let fiber = firstChild; while (fiber !== null) { - const primarySubtreeTag = fiber.subtreeTag & PassiveSubtreeTag; + const primarySubtreeFlags = fiber.subtreeFlags & PassiveSubtreeFlags; - if (fiber.child !== null && primarySubtreeTag !== NoSubtreeTag) { + if (fiber.child !== null && primarySubtreeFlags !== NoSubtreeFlags) { flushPassiveMountEffects(fiber.child); } - if ((fiber.effectTag & Update) !== NoEffect) { + if ((fiber.flags & Update) !== NoEffect) { setCurrentDebugFiberInDEV(fiber); commitPassiveEffectOnFiber(fiber); resetCurrentDebugFiberInDEV(); @@ -2694,17 +2695,17 @@ function flushPassiveUnmountEffects(firstChild: Fiber): void { const child = fiber.child; if (child !== null) { // If any children have passive effects then traverse the subtree. - // Note that this requires checking subtreeTag of the current Fiber, - // rather than the subtreeTag/effectsTag of the first child, + // Note that this requires checking subtreeFlags of the current Fiber, + // rather than the subtreeFlags/effectsTag of the first child, // since that would not cover passive effects in siblings. - const primarySubtreeTag = fiber.subtreeTag & PassiveSubtreeTag; - if (primarySubtreeTag !== NoSubtreeTag) { + const primarySubtreeFlags = fiber.subtreeFlags & PassiveSubtreeFlags; + if (primarySubtreeFlags !== NoSubtreeFlags) { flushPassiveUnmountEffects(child); } } - const primaryEffectTag = fiber.effectTag & Passive; - if (primaryEffectTag !== NoEffect) { + const primaryFlags = fiber.flags & Passive; + if (primaryFlags !== NoEffect) { setCurrentDebugFiberInDEV(fiber); commitPassiveWork(fiber); resetCurrentDebugFiberInDEV(); @@ -2718,10 +2719,13 @@ function flushPassiveUnmountEffectsInsideOfDeletedTree( fiberToDelete: Fiber, nearestMountedAncestor: Fiber, ): void { - if ((fiberToDelete.subtreeTag & PassiveStaticSubtreeTag) !== NoSubtreeTag) { + if ( + (fiberToDelete.subtreeFlags & PassiveStaticSubtreeFlags) !== + NoSubtreeFlags + ) { // If any children have passive effects then traverse the subtree. - // Note that this requires checking subtreeTag of the current Fiber, - // rather than the subtreeTag/effectsTag of the first child, + // Note that this requires checking subtreeFlags of the current Fiber, + // rather than the subtreeFlags/effectsTag of the first child, // since that would not cover passive effects in siblings. let child = fiberToDelete.child; while (child !== null) { @@ -2733,7 +2737,7 @@ function flushPassiveUnmountEffectsInsideOfDeletedTree( } } - if ((fiberToDelete.effectTag & PassiveStatic) !== NoEffect) { + if ((fiberToDelete.flags & PassiveStatic) !== NoEffect) { setCurrentDebugFiberInDEV(fiberToDelete); commitPassiveUnmount(fiberToDelete, nearestMountedAncestor); resetCurrentDebugFiberInDEV(); @@ -3162,7 +3166,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { return; } - if ((fiber.effectTag & PassiveStatic) !== NoEffect) { + if ((fiber.flags & PassiveStatic) !== NoEffect) { const updateQueue: FunctionComponentUpdateQueue | null = (fiber.updateQueue: any); if (updateQueue !== null) { const lastEffect = updateQueue.lastEffect; diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js index 97514adb03a99..19e3334a22868 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js @@ -133,7 +133,7 @@ import { HostEffectMask, Hydrating, HydratingAndUpdate, -} from './ReactSideEffectTags'; +} from './ReactFiberFlags'; import { NoLanePriority, SyncLanePriority, @@ -637,7 +637,7 @@ function markUpdateLaneFromFiberToRoot( if (__DEV__) { if ( alternate === null && - (sourceFiber.effectTag & (Placement | Hydrating)) !== NoEffect + (sourceFiber.flags & (Placement | Hydrating)) !== NoEffect ) { warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } @@ -652,7 +652,7 @@ function markUpdateLaneFromFiberToRoot( alternate.childLanes = mergeLanes(alternate.childLanes, lane); } else { if (__DEV__) { - if ((parent.effectTag & (Placement | Hydrating)) !== NoEffect) { + if ((parent.flags & (Placement | Hydrating)) !== NoEffect) { warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } } @@ -1693,7 +1693,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void { const returnFiber = completedWork.return; // Check if the work completed or if something threw. - if ((completedWork.effectTag & Incomplete) === NoEffect) { + if ((completedWork.flags & Incomplete) === NoEffect) { setCurrentDebugFiberInDEV(completedWork); let next; if ( @@ -1720,7 +1720,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void { if ( returnFiber !== null && // Do not append effects to parents if a sibling failed to complete - (returnFiber.effectTag & Incomplete) === NoEffect + (returnFiber.flags & Incomplete) === NoEffect ) { // Append all the effects of the subtree and this fiber onto the effect // list of the parent. The completion order of the children affects the @@ -1741,12 +1741,12 @@ function completeUnitOfWork(unitOfWork: Fiber): void { // schedule our own side-effect on our own list because if end up // reusing children we'll schedule this effect onto itself since we're // at the end. - const effectTag = completedWork.effectTag; + const flags = completedWork.flags; // Skip both NoWork and PerformedWork tags when creating the effect // list. PerformedWork effect is read by React DevTools but shouldn't be // committed. - if (effectTag > PerformedWork) { + if (flags > PerformedWork) { if (returnFiber.lastEffect !== null) { returnFiber.lastEffect.nextEffect = completedWork; } else { @@ -1768,7 +1768,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void { // back here again. // Since we're restarting, remove anything that is not a host effect // from the effect tag. - next.effectTag &= HostEffectMask; + next.flags &= HostEffectMask; workInProgress = next; return; } @@ -1793,7 +1793,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void { if (returnFiber !== null) { // Mark the parent fiber as incomplete and clear its effect list. returnFiber.firstEffect = returnFiber.lastEffect = null; - returnFiber.effectTag |= Incomplete; + returnFiber.flags |= Incomplete; } } @@ -1985,7 +1985,7 @@ function commitRootImpl(root, renderPriorityLevel) { // Get the list of effects. let firstEffect; - if (finishedWork.effectTag > PerformedWork) { + if (finishedWork.flags > PerformedWork) { // A fiber's effect list consists only of its children, not itself. So if // the root has an effect, we need to add it to the end of the list. The // resulting list is the set that would belong to the root's parent, if it @@ -2161,7 +2161,7 @@ function commitRootImpl(root, renderPriorityLevel) { while (nextEffect !== null) { const nextNextEffect = nextEffect.nextEffect; nextEffect.nextEffect = null; - if (nextEffect.effectTag & Deletion) { + if (nextEffect.flags & Deletion) { detachFiberAfterEffects(nextEffect); } nextEffect = nextNextEffect; @@ -2272,7 +2272,7 @@ function commitBeforeMutationEffects() { const current = nextEffect.alternate; if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - if ((nextEffect.effectTag & Deletion) !== NoEffect) { + if ((nextEffect.flags & Deletion) !== NoEffect) { if (doesFiberContain(nextEffect, focusedInstanceHandle)) { shouldFireAfterActiveInstanceBlur = true; beforeActiveInstanceBlur(); @@ -2290,15 +2290,15 @@ function commitBeforeMutationEffects() { } } - const effectTag = nextEffect.effectTag; - if ((effectTag & Snapshot) !== NoEffect) { + const flags = nextEffect.flags; + if ((flags & Snapshot) !== NoEffect) { setCurrentDebugFiberInDEV(nextEffect); commitBeforeMutationEffectOnFiber(current, nextEffect); resetCurrentDebugFiberInDEV(); } - if ((effectTag & Passive) !== NoEffect) { + if ((flags & Passive) !== NoEffect) { // If there are passive effects, schedule a callback to flush at // the earliest opportunity. if (!rootDoesHavePassiveEffects) { @@ -2321,13 +2321,13 @@ function commitMutationEffects( while (nextEffect !== null) { setCurrentDebugFiberInDEV(nextEffect); - const effectTag = nextEffect.effectTag; + const flags = nextEffect.flags; - if (effectTag & ContentReset) { + if (flags & ContentReset) { commitResetTextContent(nextEffect); } - if (effectTag & Ref) { + if (flags & Ref) { const current = nextEffect.alternate; if (current !== null) { commitDetachRef(current); @@ -2345,16 +2345,15 @@ function commitMutationEffects( // updates, and deletions. To avoid needing to add a case for every possible // bitmap value, we remove the secondary effects from the effect tag and // switch on that value. - const primaryEffectTag = - effectTag & (Placement | Update | Deletion | Hydrating); - switch (primaryEffectTag) { + const primaryFlags = flags & (Placement | Update | Deletion | Hydrating); + switch (primaryFlags) { case Placement: { commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is // inserted, before any life-cycles like componentDidMount gets called. // TODO: findDOMNode doesn't rely on this any more but isMounted does // and isMounted is deprecated anyway so we should be able to kill this. - nextEffect.effectTag &= ~Placement; + nextEffect.flags &= ~Placement; break; } case PlacementAndUpdate: { @@ -2362,7 +2361,7 @@ function commitMutationEffects( commitPlacement(nextEffect); // Clear the "placement" from effect tag so that we know that this is // inserted, before any life-cycles like componentDidMount gets called. - nextEffect.effectTag &= ~Placement; + nextEffect.flags &= ~Placement; // Update const current = nextEffect.alternate; @@ -2370,11 +2369,11 @@ function commitMutationEffects( break; } case Hydrating: { - nextEffect.effectTag &= ~Hydrating; + nextEffect.flags &= ~Hydrating; break; } case HydratingAndUpdate: { - nextEffect.effectTag &= ~Hydrating; + nextEffect.flags &= ~Hydrating; // Update const current = nextEffect.alternate; @@ -2417,9 +2416,9 @@ function commitLayoutEffects(root: FiberRoot, committedLanes: Lanes) { while (nextEffect !== null) { setCurrentDebugFiberInDEV(nextEffect); - const effectTag = nextEffect.effectTag; + const flags = nextEffect.flags; - if (effectTag & (Update | Callback)) { + if (flags & (Update | Callback)) { const current = nextEffect.alternate; commitLayoutEffectOnFiber(root, current, nextEffect, committedLanes); } @@ -2427,11 +2426,11 @@ function commitLayoutEffects(root: FiberRoot, committedLanes: Lanes) { if (enableScopeAPI) { // TODO: This is a temporary solution that allowed us to transition away // from React Flare on www. - if (effectTag & Ref && nextEffect.tag !== ScopeComponent) { + if (flags & Ref && nextEffect.tag !== ScopeComponent) { commitAttachRef(nextEffect); } } else { - if (effectTag & Ref) { + if (flags & Ref) { commitAttachRef(nextEffect); } } @@ -2509,10 +2508,10 @@ export function enqueuePendingPassiveHookEffectUnmount( ): void { pendingPassiveHookEffectsUnmount.push(effect, fiber); if (__DEV__) { - fiber.effectTag |= PassiveUnmountPendingDev; + fiber.flags |= PassiveUnmountPendingDev; const alternate = fiber.alternate; if (alternate !== null) { - alternate.effectTag |= PassiveUnmountPendingDev; + alternate.flags |= PassiveUnmountPendingDev; } } if (!rootDoesHavePassiveEffects) { @@ -2579,10 +2578,10 @@ function flushPassiveEffectsImpl() { effect.destroy = undefined; if (__DEV__) { - fiber.effectTag &= ~PassiveUnmountPendingDev; + fiber.flags &= ~PassiveUnmountPendingDev; const alternate = fiber.alternate; if (alternate !== null) { - alternate.effectTag &= ~PassiveUnmountPendingDev; + alternate.flags &= ~PassiveUnmountPendingDev; } } @@ -2686,7 +2685,7 @@ function flushPassiveEffectsImpl() { const nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC effect.nextEffect = null; - if (effect.effectTag & Deletion) { + if (effect.flags & Deletion) { detachFiberAfterEffects(effect); } effect = nextNextEffect; @@ -3092,7 +3091,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { // If there are pending passive effects unmounts for this Fiber, // we can assume that they would have prevented this update. - if ((fiber.effectTag & PassiveUnmountPendingDev) !== NoEffect) { + if ((fiber.flags & PassiveUnmountPendingDev) !== NoEffect) { return; } diff --git a/packages/react-reconciler/src/ReactHookEffectTags.js b/packages/react-reconciler/src/ReactHookEffectTags.js index 709b5b891e8fa..5b2d2638f1dc0 100644 --- a/packages/react-reconciler/src/ReactHookEffectTags.js +++ b/packages/react-reconciler/src/ReactHookEffectTags.js @@ -7,7 +7,7 @@ * @flow */ -export type HookEffectTag = number; +export type HookFlags = number; export const NoEffect = /* */ 0b000; diff --git a/packages/react-reconciler/src/ReactInternalTypes.js b/packages/react-reconciler/src/ReactInternalTypes.js index ef7d1ea7633a1..728aadf3f8af2 100644 --- a/packages/react-reconciler/src/ReactInternalTypes.js +++ b/packages/react-reconciler/src/ReactInternalTypes.js @@ -19,8 +19,8 @@ import type { import type {SuspenseInstance} from './ReactFiberHostConfig'; import type {WorkTag} from './ReactWorkTags'; import type {TypeOfMode} from './ReactTypeOfMode'; -import type {SideEffectTag} from './ReactSideEffectTags'; -import type {SubtreeTag} from './ReactSubtreeTags'; +import type {Flags} from './ReactFiberFlags'; +import type {SubtreeFlags} from './ReactSubtreeFlags'; import type {Lane, LanePriority, Lanes, LaneMap} from './ReactFiberLane'; import type {HookType} from './ReactFiberHooks.old'; import type {RootTag} from './ReactRootTags'; @@ -118,8 +118,8 @@ export type Fiber = {| mode: TypeOfMode, // Effect - effectTag: SideEffectTag, - subtreeTag: SubtreeTag, + flags: Flags, + subtreeFlags: SubtreeFlags, deletions: Array | null, // Singly linked list fast path to the next fiber with side-effects. diff --git a/packages/react-reconciler/src/ReactSubtreeTags.js b/packages/react-reconciler/src/ReactSubtreeFlags.js similarity index 81% rename from packages/react-reconciler/src/ReactSubtreeTags.js rename to packages/react-reconciler/src/ReactSubtreeFlags.js index 6223fe8bca1ca..e07265b740948 100644 --- a/packages/react-reconciler/src/ReactSubtreeTags.js +++ b/packages/react-reconciler/src/ReactSubtreeFlags.js @@ -7,7 +7,8 @@ * @flow */ -export type SubtreeTag = number; +// TODO: Move this to ReactFiberFlags so it's easier to line up the bits +export type SubtreeFlags = number; export const NoEffect = /* */ 0b00000; export const BeforeMutation = /* */ 0b00001; diff --git a/packages/react-reconciler/src/ReactUpdateQueue.new.js b/packages/react-reconciler/src/ReactUpdateQueue.new.js index 303e02f07d609..f745445a1e387 100644 --- a/packages/react-reconciler/src/ReactUpdateQueue.new.js +++ b/packages/react-reconciler/src/ReactUpdateQueue.new.js @@ -92,7 +92,7 @@ import { enterDisallowedContextReadInDEV, exitDisallowedContextReadInDEV, } from './ReactFiberNewContext.new'; -import {Callback, ShouldCapture, DidCapture} from './ReactSideEffectTags'; +import {Callback, ShouldCapture, DidCapture} from './ReactFiberFlags'; import {debugRenderPhaseSideEffectsForStrictMode} from 'shared/ReactFeatureFlags'; @@ -345,8 +345,8 @@ function getStateFromUpdate( return payload; } case CaptureUpdate: { - workInProgress.effectTag = - (workInProgress.effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = + (workInProgress.flags & ~ShouldCapture) | DidCapture; } // Intentional fallthrough case UpdateState: { @@ -517,7 +517,7 @@ export function processUpdateQueue( ); const callback = update.callback; if (callback !== null) { - workInProgress.effectTag |= Callback; + workInProgress.flags |= Callback; const effects = queue.effects; if (effects === null) { queue.effects = [update]; diff --git a/packages/react-reconciler/src/ReactUpdateQueue.old.js b/packages/react-reconciler/src/ReactUpdateQueue.old.js index 787ec3d18c3a3..4eccd78d12343 100644 --- a/packages/react-reconciler/src/ReactUpdateQueue.old.js +++ b/packages/react-reconciler/src/ReactUpdateQueue.old.js @@ -92,7 +92,7 @@ import { enterDisallowedContextReadInDEV, exitDisallowedContextReadInDEV, } from './ReactFiberNewContext.old'; -import {Callback, ShouldCapture, DidCapture} from './ReactSideEffectTags'; +import {Callback, ShouldCapture, DidCapture} from './ReactFiberFlags'; import {debugRenderPhaseSideEffectsForStrictMode} from 'shared/ReactFeatureFlags'; @@ -345,8 +345,8 @@ function getStateFromUpdate( return payload; } case CaptureUpdate: { - workInProgress.effectTag = - (workInProgress.effectTag & ~ShouldCapture) | DidCapture; + workInProgress.flags = + (workInProgress.flags & ~ShouldCapture) | DidCapture; } // Intentional fallthrough case UpdateState: { @@ -517,7 +517,7 @@ export function processUpdateQueue( ); const callback = update.callback; if (callback !== null) { - workInProgress.effectTag |= Callback; + workInProgress.flags |= Callback; const effects = queue.effects; if (effects === null) { queue.effects = [update]; diff --git a/scripts/eslint-rules/__tests__/no-cross-fork-types-test.internal.js b/scripts/eslint-rules/__tests__/no-cross-fork-types-test.internal.js index 57c50a55b315f..93a3c7e663e45 100644 --- a/scripts/eslint-rules/__tests__/no-cross-fork-types-test.internal.js +++ b/scripts/eslint-rules/__tests__/no-cross-fork-types-test.internal.js @@ -74,9 +74,9 @@ const {key_new} = obj; errors: [{message: oldAccessWarning}], }, { - code: 'const subtreeTag = obj.subtreeTag;', + code: 'const subtreeFlags = obj.subtreeFlags;', filename: 'ReactFiberWorkLoop.old.js', - options: [{new: ['subtreeTag']}], + options: [{new: ['subtreeFlags']}], errors: [{message: newAccessWarning}], }, {