diff --git a/packages/react-dom/src/__tests__/ReactDOMRoot-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMRoot-test.internal.js
index 4972cac245b94..1859ff4d62292 100644
--- a/packages/react-dom/src/__tests__/ReactDOMRoot-test.internal.js
+++ b/packages/react-dom/src/__tests__/ReactDOMRoot-test.internal.js
@@ -209,7 +209,6 @@ describe('ReactDOMRoot', () => {
});
it('can wait for a batch to finish', () => {
- const AsyncMode = React.Unstable_AsyncMode;
const root = ReactDOM.createRoot(container);
const batch = root.createBatch();
batch.render(Foo);
diff --git a/packages/react-reconciler/src/ReactChildFiber.js b/packages/react-reconciler/src/ReactChildFiber.js
index 1722bf81263df..b1886ad0a6933 100644
--- a/packages/react-reconciler/src/ReactChildFiber.js
+++ b/packages/react-reconciler/src/ReactChildFiber.js
@@ -318,7 +318,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// Insert
const created = createFiberFromText(
textContent,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
@@ -351,7 +351,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// Insert
const created = createFiberFromElement(
element,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
);
created.ref = coerceRef(current, element);
@@ -375,7 +375,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// Insert
const created = createFiberFromPortal(
portal,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
@@ -399,7 +399,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// Insert
const created = createFiberFromFragment(
fragment,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
key,
);
@@ -424,7 +424,7 @@ function ChildReconciler(shouldTrackSideEffects) {
// node.
const created = createFiberFromText(
'' + newChild,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
@@ -436,7 +436,7 @@ function ChildReconciler(shouldTrackSideEffects) {
case REACT_ELEMENT_TYPE: {
const created = createFiberFromElement(
newChild,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
);
created.ref = coerceRef(null, newChild);
@@ -446,7 +446,7 @@ function ChildReconciler(shouldTrackSideEffects) {
case REACT_PORTAL_TYPE: {
const created = createFiberFromPortal(
newChild,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
@@ -457,7 +457,7 @@ function ChildReconciler(shouldTrackSideEffects) {
if (isArray(newChild) || getIteratorFn(newChild)) {
const created = createFiberFromFragment(
newChild,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
null,
);
@@ -1045,7 +1045,7 @@ function ChildReconciler(shouldTrackSideEffects) {
deleteRemainingChildren(returnFiber, currentFirstChild);
const created = createFiberFromText(
textContent,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
@@ -1097,7 +1097,7 @@ function ChildReconciler(shouldTrackSideEffects) {
if (element.type === REACT_FRAGMENT_TYPE) {
const created = createFiberFromFragment(
element.props.children,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
element.key,
);
@@ -1106,7 +1106,7 @@ function ChildReconciler(shouldTrackSideEffects) {
} else {
const created = createFiberFromElement(
element,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
);
created.ref = coerceRef(currentFirstChild, element);
@@ -1152,7 +1152,7 @@ function ChildReconciler(shouldTrackSideEffects) {
const created = createFiberFromPortal(
portal,
- returnFiber.internalContextTag,
+ returnFiber.mode,
expirationTime,
);
created.return = returnFiber;
diff --git a/packages/react-reconciler/src/ReactFiber.js b/packages/react-reconciler/src/ReactFiber.js
index a7a3bdb36d893..a5f7cd7a3e666 100644
--- a/packages/react-reconciler/src/ReactFiber.js
+++ b/packages/react-reconciler/src/ReactFiber.js
@@ -9,7 +9,7 @@
import type {ReactElement, Source} from 'shared/ReactElementType';
import type {ReactPortal} from 'shared/ReactTypes';
import type {TypeOfWork} from 'shared/ReactTypeOfWork';
-import type {TypeOfInternalContext} from './ReactTypeOfInternalContext';
+import type {TypeOfMode} from './ReactTypeOfMode';
import type {TypeOfSideEffect} from 'shared/ReactTypeOfSideEffect';
import type {ExpirationTime} from './ReactFiberExpirationTime';
import type {UpdateQueue} from './ReactFiberUpdateQueue';
@@ -33,7 +33,7 @@ import {
import getComponentName from 'shared/getComponentName';
import {NoWork} from './ReactFiberExpirationTime';
-import {NoContext, AsyncMode, StrictMode} from './ReactTypeOfInternalContext';
+import {NoContext, AsyncMode, StrictMode} from './ReactTypeOfMode';
import {
REACT_FRAGMENT_TYPE,
REACT_RETURN_TYPE,
@@ -121,11 +121,11 @@ export type Fiber = {|
// Bitfield that describes properties about the fiber and its subtree. E.g.
// the AsyncMode flag indicates whether the subtree should be async-by-
- // default. When a fiber is created, it inherits the internalContextTag of its
+ // default. When a fiber is created, it inherits the mode of its
// parent. Additional flags can be set at creation time, but after than the
// value should remain unchanged throughout the fiber's lifetime, particularly
// before its child fibers are created.
- internalContextTag: TypeOfInternalContext,
+ mode: TypeOfMode,
// Effect
effectTag: TypeOfSideEffect,
@@ -168,7 +168,7 @@ function FiberNode(
tag: TypeOfWork,
pendingProps: mixed,
key: null | string,
- internalContextTag: TypeOfInternalContext,
+ mode: TypeOfMode,
) {
// Instance
this.tag = tag;
@@ -189,7 +189,7 @@ function FiberNode(
this.updateQueue = null;
this.memoizedState = null;
- this.internalContextTag = internalContextTag;
+ this.mode = mode;
// Effects
this.effectTag = NoEffect;
@@ -230,10 +230,10 @@ const createFiber = function(
tag: TypeOfWork,
pendingProps: mixed,
key: null | string,
- internalContextTag: TypeOfInternalContext,
+ mode: TypeOfMode,
): Fiber {
// $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
- return new FiberNode(tag, pendingProps, key, internalContextTag);
+ return new FiberNode(tag, pendingProps, key, mode);
};
function shouldConstruct(Component) {
@@ -257,7 +257,7 @@ export function createWorkInProgress(
current.tag,
pendingProps,
current.key,
- current.internalContextTag,
+ current.mode,
);
workInProgress.type = current.type;
workInProgress.stateNode = current.stateNode;
@@ -300,13 +300,13 @@ export function createWorkInProgress(
}
export function createHostRootFiber(isAsync): Fiber {
- const internalContextTag = isAsync ? AsyncMode | StrictMode : NoContext;
- return createFiber(HostRoot, null, null, internalContextTag);
+ const mode = isAsync ? AsyncMode | StrictMode : NoContext;
+ return createFiber(HostRoot, null, null, mode);
}
export function createFiberFromElement(
element: ReactElement,
- internalContextTag: TypeOfInternalContext,
+ mode: TypeOfMode,
expirationTime: ExpirationTime,
): Fiber {
let owner = null;
@@ -329,17 +329,17 @@ export function createFiberFromElement(
case REACT_FRAGMENT_TYPE:
return createFiberFromFragment(
pendingProps.children,
- internalContextTag,
+ mode,
expirationTime,
key,
);
case REACT_ASYNC_MODE_TYPE:
fiberTag = Mode;
- internalContextTag |= AsyncMode | StrictMode;
+ mode |= AsyncMode | StrictMode;
break;
case REACT_STRICT_MODE_TYPE:
fiberTag = Mode;
- internalContextTag |= StrictMode;
+ mode |= StrictMode;
break;
case REACT_CALL_TYPE:
fiberTag = CallComponent;
@@ -383,7 +383,7 @@ export function createFiberFromElement(
}
}
- fiber = createFiber(fiberTag, pendingProps, key, internalContextTag);
+ fiber = createFiber(fiberTag, pendingProps, key, mode);
fiber.type = type;
fiber.expirationTime = expirationTime;
@@ -426,21 +426,21 @@ function throwOnInvalidElementType(type, owner) {
export function createFiberFromFragment(
elements: ReactFragment,
- internalContextTag: TypeOfInternalContext,
+ mode: TypeOfMode,
expirationTime: ExpirationTime,
key: null | string,
): Fiber {
- const fiber = createFiber(Fragment, elements, key, internalContextTag);
+ const fiber = createFiber(Fragment, elements, key, mode);
fiber.expirationTime = expirationTime;
return fiber;
}
export function createFiberFromText(
content: string,
- internalContextTag: TypeOfInternalContext,
+ mode: TypeOfMode,
expirationTime: ExpirationTime,
): Fiber {
- const fiber = createFiber(HostText, content, null, internalContextTag);
+ const fiber = createFiber(HostText, content, null, mode);
fiber.expirationTime = expirationTime;
return fiber;
}
@@ -453,16 +453,11 @@ export function createFiberFromHostInstanceForDeletion(): Fiber {
export function createFiberFromPortal(
portal: ReactPortal,
- internalContextTag: TypeOfInternalContext,
+ mode: TypeOfMode,
expirationTime: ExpirationTime,
): Fiber {
const pendingProps = portal.children !== null ? portal.children : [];
- const fiber = createFiber(
- HostPortal,
- pendingProps,
- portal.key,
- internalContextTag,
- );
+ const fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
fiber.expirationTime = expirationTime;
fiber.stateNode = {
containerInfo: portal.containerInfo,
diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js
index 285b04865faa0..e4732b78467aa 100644
--- a/packages/react-reconciler/src/ReactFiberBeginWork.js
+++ b/packages/react-reconciler/src/ReactFiberBeginWork.js
@@ -67,7 +67,7 @@ import {
} from './ReactFiberContext';
import {pushProvider} from './ReactFiberNewContext';
import {NoWork, Never} from './ReactFiberExpirationTime';
-import {AsyncMode, StrictMode} from './ReactTypeOfInternalContext';
+import {AsyncMode, StrictMode} from './ReactTypeOfMode';
import MAX_SIGNED_31_BIT_INT from './maxSigned31BitInt';
let didWarnAboutBadClass;
@@ -293,7 +293,7 @@ export default function(
if (
debugRenderPhaseSideEffects ||
(debugRenderPhaseSideEffectsForStrictMode &&
- workInProgress.internalContextTag & StrictMode)
+ workInProgress.mode & StrictMode)
) {
instance.render();
}
@@ -302,7 +302,7 @@ export default function(
if (
debugRenderPhaseSideEffects ||
(debugRenderPhaseSideEffectsForStrictMode &&
- workInProgress.internalContextTag & StrictMode)
+ workInProgress.mode & StrictMode)
) {
instance.render();
}
@@ -438,7 +438,7 @@ export default function(
// Check the host config to see if the children are offscreen/hidden.
if (
renderExpirationTime !== Never &&
- workInProgress.internalContextTag & AsyncMode &&
+ workInProgress.mode & AsyncMode &&
shouldDeprioritizeSubtree(type, nextProps)
) {
// Down-prioritize the children.
diff --git a/packages/react-reconciler/src/ReactFiberClassComponent.js b/packages/react-reconciler/src/ReactFiberClassComponent.js
index 7dec906d28678..3752b5c368b48 100644
--- a/packages/react-reconciler/src/ReactFiberClassComponent.js
+++ b/packages/react-reconciler/src/ReactFiberClassComponent.js
@@ -26,7 +26,7 @@ import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
import {startPhaseTimer, stopPhaseTimer} from './ReactDebugFiberPerf';
-import {StrictMode} from './ReactTypeOfInternalContext';
+import {StrictMode} from './ReactTypeOfMode';
import {
cacheContext,
getMaskedContext,
@@ -394,7 +394,7 @@ export default function(
if (
debugRenderPhaseSideEffects ||
(debugRenderPhaseSideEffectsForStrictMode &&
- workInProgress.internalContextTag & StrictMode)
+ workInProgress.mode & StrictMode)
) {
new ctor(props, context); // eslint-disable-line no-new
}
@@ -547,7 +547,7 @@ export default function(
if (
debugRenderPhaseSideEffects ||
(debugRenderPhaseSideEffectsForStrictMode &&
- workInProgress.internalContextTag & StrictMode)
+ workInProgress.mode & StrictMode)
) {
// Invoke method an extra time to help detect side-effects.
type.getDerivedStateFromProps.call(
@@ -602,12 +602,8 @@ export default function(
instance.refs = emptyObject;
instance.context = getMaskedContext(workInProgress, unmaskedContext);
- if (workInProgress.type != null && workInProgress.type.prototype != null) {
- const prototype = workInProgress.type.prototype;
- }
-
if (__DEV__) {
- if (workInProgress.internalContextTag & StrictMode) {
+ if (workInProgress.mode & StrictMode) {
ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(
workInProgress,
instance,
diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js
index a319c2ec97457..0ff8f1f8217f3 100644
--- a/packages/react-reconciler/src/ReactFiberScheduler.js
+++ b/packages/react-reconciler/src/ReactFiberScheduler.js
@@ -81,7 +81,7 @@ import {
expirationTimeToMs,
computeExpirationBucket,
} from './ReactFiberExpirationTime';
-import {AsyncMode} from './ReactTypeOfInternalContext';
+import {AsyncMode} from './ReactTypeOfMode';
import {getUpdateExpirationTime} from './ReactFiberUpdateQueue';
import {resetContext as resetLegacyContext} from './ReactFiberContext';
import {resetProviderStack} from './ReactFiberNewContext';
@@ -1200,7 +1200,7 @@ export default function(
} else {
// No explicit expiration context was set, and we're not currently
// performing work. Calculate a new expiration time.
- if (fiber.internalContextTag & AsyncMode) {
+ if (fiber.mode & AsyncMode) {
// This is an async update
expirationTime = computeAsyncExpiration();
} else {
diff --git a/packages/react-reconciler/src/ReactFiberUpdateQueue.js b/packages/react-reconciler/src/ReactFiberUpdateQueue.js
index 24fae562e6f43..3967149e28e5c 100644
--- a/packages/react-reconciler/src/ReactFiberUpdateQueue.js
+++ b/packages/react-reconciler/src/ReactFiberUpdateQueue.js
@@ -18,7 +18,7 @@ import {Callback as CallbackEffect} from 'shared/ReactTypeOfSideEffect';
import {ClassComponent, HostRoot} from 'shared/ReactTypeOfWork';
import invariant from 'fbjs/lib/invariant';
import warning from 'fbjs/lib/warning';
-import {StrictMode} from './ReactTypeOfInternalContext';
+import {StrictMode} from './ReactTypeOfMode';
import {NoWork} from './ReactFiberExpirationTime';
@@ -278,7 +278,7 @@ export function processUpdateQueue(
if (
debugRenderPhaseSideEffects ||
(debugRenderPhaseSideEffectsForStrictMode &&
- workInProgress.internalContextTag & StrictMode)
+ workInProgress.mode & StrictMode)
) {
getStateFromUpdate(update, instance, state, props);
}
diff --git a/packages/react-reconciler/src/ReactStrictModeWarnings.js b/packages/react-reconciler/src/ReactStrictModeWarnings.js
index 8be9b1dc50936..3be8c16aeee62 100644
--- a/packages/react-reconciler/src/ReactStrictModeWarnings.js
+++ b/packages/react-reconciler/src/ReactStrictModeWarnings.js
@@ -11,7 +11,7 @@ import type {Fiber} from './ReactFiber';
import getComponentName from 'shared/getComponentName';
import {getStackAddendumByWorkInProgressFiber} from 'shared/ReactFiberComponentTreeHook';
-import {StrictMode} from './ReactTypeOfInternalContext';
+import {StrictMode} from './ReactTypeOfMode';
import warning from 'fbjs/lib/warning';
type LIFECYCLE =
@@ -104,7 +104,7 @@ if (__DEV__) {
let maybeStrictRoot = null;
while (fiber !== null) {
- if (fiber.internalContextTag & StrictMode) {
+ if (fiber.mode & StrictMode) {
maybeStrictRoot = fiber;
}
diff --git a/packages/react-reconciler/src/ReactTypeOfInternalContext.js b/packages/react-reconciler/src/ReactTypeOfMode.js
similarity index 86%
rename from packages/react-reconciler/src/ReactTypeOfInternalContext.js
rename to packages/react-reconciler/src/ReactTypeOfMode.js
index 3729b1a97f6ef..e93b4d984ded9 100644
--- a/packages/react-reconciler/src/ReactTypeOfInternalContext.js
+++ b/packages/react-reconciler/src/ReactTypeOfMode.js
@@ -7,7 +7,7 @@
* @flow
*/
-export type TypeOfInternalContext = number;
+export type TypeOfMode = number;
export const NoContext = 0b00;
export const AsyncMode = 0b01;