Skip to content

Remove feature flag enableRenderableContext #33505

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions packages/react-client/src/ReactFlightReplyClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ import type {
import type {LazyComponent} from 'react/src/ReactLazy';
import type {TemporaryReferenceSet} from './ReactFlightTemporaryReferences';

import {enableRenderableContext} from 'shared/ReactFeatureFlags';

import {
REACT_ELEMENT_TYPE,
REACT_LAZY_TYPE,
REACT_CONTEXT_TYPE,
REACT_PROVIDER_TYPE,
getIteratorFn,
ASYNC_ITERATOR,
} from 'shared/ReactSymbols';
Expand Down Expand Up @@ -699,10 +696,7 @@ export function processReply(
return serializeTemporaryReferenceMarker();
}
if (__DEV__) {
if (
(value: any).$$typeof ===
(enableRenderableContext ? REACT_CONTEXT_TYPE : REACT_PROVIDER_TYPE)
) {
if ((value: any).$$typeof === REACT_CONTEXT_TYPE) {
console.error(
'React Context Providers cannot be passed to Server Functions from the Client.%s',
describeObjectForErrorMessage(parent, key),
Expand Down
16 changes: 5 additions & 11 deletions packages/react-devtools-shared/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ import {
REACT_MEMO_TYPE,
REACT_PORTAL_TYPE,
REACT_PROFILER_TYPE,
REACT_PROVIDER_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_SUSPENSE_LIST_TYPE,
REACT_SUSPENSE_TYPE,
REACT_TRACING_MARKER_TYPE,
REACT_VIEW_TRANSITION_TYPE,
} from 'shared/ReactSymbols';
import {enableRenderableContext} from 'shared/ReactFeatureFlags';
import {
TREE_OPERATION_ADD,
TREE_OPERATION_REMOVE,
Expand Down Expand Up @@ -87,6 +85,9 @@ const encodedStringCache: LRUCache<string, Array<number>> = new LRU({
max: 1000,
});

// Previously, the type of `Context.Provider`.
const LEGACY_REACT_PROVIDER_TYPE: symbol = Symbol.for('react.provider');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you have another way to deal with devtools needing to support older React runtimes? I just moved the otherwise deleted constant here…


export function alphaSortKeys(
a: string | number | symbol,
b: string | number | symbol,
Expand Down Expand Up @@ -712,14 +713,7 @@ function typeOfWithLegacyElementSymbol(object: any): mixed {
case REACT_MEMO_TYPE:
return $$typeofType;
case REACT_CONSUMER_TYPE:
if (enableRenderableContext) {
return $$typeofType;
}
// Fall through
case REACT_PROVIDER_TYPE:
if (!enableRenderableContext) {
return $$typeofType;
}
return $$typeofType;
// Fall through
default:
return $$typeof;
Expand All @@ -740,7 +734,7 @@ export function getDisplayNameForReactElement(
switch (elementType) {
case REACT_CONSUMER_TYPE:
return 'ContextConsumer';
case REACT_PROVIDER_TYPE:
case LEGACY_REACT_PROVIDER_TYPE:
return 'ContextProvider';
case REACT_CONTEXT_TYPE:
return 'Context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,6 @@ describe('ReactDOMServerIntegration', () => {
});

itRenders('should treat Context as Context.Provider', async render => {
// The `itRenders` helpers don't work with the gate pragma, so we have to do
// this instead.
if (gate(flags => !flags.enableRenderableContext)) {
return;
}

const Theme = React.createContext('dark');
const Language = React.createContext('french');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,6 @@ describe('ReactDOMServer', () => {
]);
});

// @gate enableRenderableContext || !__DEV__
it('should warn if an invalid contextType is defined', () => {
const Context = React.createContext();
class ComponentA extends React.Component {
Expand Down
34 changes: 6 additions & 28 deletions packages/react-is/src/ReactIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
REACT_MEMO_TYPE,
REACT_PORTAL_TYPE,
REACT_PROFILER_TYPE,
REACT_PROVIDER_TYPE,
REACT_CONSUMER_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_SUSPENSE_TYPE,
Expand All @@ -30,7 +29,6 @@ import {
} from 'shared/ReactSymbols';

import {
enableRenderableContext,
enableScopeAPI,
enableTransitionTracing,
enableLegacyHidden,
Expand Down Expand Up @@ -64,14 +62,7 @@ export function typeOf(object: any): mixed {
case REACT_MEMO_TYPE:
return $$typeofType;
case REACT_CONSUMER_TYPE:
if (enableRenderableContext) {
return $$typeofType;
}
// Fall through
case REACT_PROVIDER_TYPE:
if (!enableRenderableContext) {
return $$typeofType;
}
return $$typeofType;
// Fall through
default:
return $$typeof;
Expand All @@ -85,12 +76,8 @@ export function typeOf(object: any): mixed {
return undefined;
}

export const ContextConsumer: symbol = enableRenderableContext
? REACT_CONSUMER_TYPE
: REACT_CONTEXT_TYPE;
export const ContextProvider: symbol = enableRenderableContext
? REACT_CONTEXT_TYPE
: REACT_PROVIDER_TYPE;
export const ContextConsumer: symbol = REACT_CONSUMER_TYPE;
export const ContextProvider: symbol = REACT_CONTEXT_TYPE;
export const Element = REACT_ELEMENT_TYPE;
export const ForwardRef = REACT_FORWARD_REF_TYPE;
export const Fragment = REACT_FRAGMENT_TYPE;
Expand Down Expand Up @@ -127,8 +114,7 @@ export function isValidElementType(type: mixed): boolean {
type.$$typeof === REACT_LAZY_TYPE ||
type.$$typeof === REACT_MEMO_TYPE ||
type.$$typeof === REACT_CONTEXT_TYPE ||
(!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) ||
(enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) ||
type.$$typeof === REACT_CONSUMER_TYPE ||
type.$$typeof === REACT_FORWARD_REF_TYPE ||
// This needs to include all possible module reference object
// types supported by any Flight configuration anywhere since
Expand All @@ -145,18 +131,10 @@ export function isValidElementType(type: mixed): boolean {
}

export function isContextConsumer(object: any): boolean {
if (enableRenderableContext) {
return typeOf(object) === REACT_CONSUMER_TYPE;
} else {
return typeOf(object) === REACT_CONTEXT_TYPE;
}
return typeOf(object) === REACT_CONSUMER_TYPE;
}
export function isContextProvider(object: any): boolean {
if (enableRenderableContext) {
return typeOf(object) === REACT_CONTEXT_TYPE;
} else {
return typeOf(object) === REACT_PROVIDER_TYPE;
}
return typeOf(object) === REACT_CONTEXT_TYPE;
}
export function isElement(object: any): boolean {
return (
Expand Down
23 changes: 4 additions & 19 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
enableLegacyHidden,
enableTransitionTracing,
enableDO_NOT_USE_disableStrictPassiveEffect,
enableRenderableContext,
disableLegacyMode,
enableObjectFiber,
enableViewTransition,
Expand Down Expand Up @@ -101,7 +100,6 @@ import {
REACT_FRAGMENT_TYPE,
REACT_STRICT_MODE_TYPE,
REACT_PROFILER_TYPE,
REACT_PROVIDER_TYPE,
REACT_CONTEXT_TYPE,
REACT_CONSUMER_TYPE,
REACT_SUSPENSE_TYPE,
Expand Down Expand Up @@ -638,25 +636,12 @@ export function createFiberFromTypeAndProps(
default: {
if (typeof type === 'object' && type !== null) {
switch (type.$$typeof) {
case REACT_PROVIDER_TYPE:
if (!enableRenderableContext) {
fiberTag = ContextProvider;
break getTag;
}
// Fall through
case REACT_CONTEXT_TYPE:
if (enableRenderableContext) {
fiberTag = ContextProvider;
break getTag;
} else {
fiberTag = ContextConsumer;
break getTag;
}
fiberTag = ContextProvider;
break getTag;
case REACT_CONSUMER_TYPE:
if (enableRenderableContext) {
fiberTag = ContextConsumer;
break getTag;
}
fiberTag = ContextConsumer;
break getTag;
// Fall through
case REACT_FORWARD_REF_TYPE:
fiberTag = ForwardRef;
Expand Down
29 changes: 4 additions & 25 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ import {
enableLegacyHidden,
enableCPUSuspense,
enablePostpone,
enableRenderableContext,
disableLegacyMode,
disableDefaultPropsExceptForClasses,
enableHydrationLaneScheduling,
Expand Down Expand Up @@ -3591,12 +3590,7 @@ function updateContextProvider(
workInProgress: Fiber,
renderLanes: Lanes,
) {
let context: ReactContext<any>;
if (enableRenderableContext) {
context = workInProgress.type;
} else {
context = workInProgress.type._context;
}
const context: ReactContext<any> = workInProgress.type;
const newProps = workInProgress.pendingProps;
const newValue = newProps.value;

Expand All @@ -3623,18 +3617,8 @@ function updateContextConsumer(
workInProgress: Fiber,
renderLanes: Lanes,
) {
let context: ReactContext<any>;
if (enableRenderableContext) {
const consumerType: ReactConsumerType<any> = workInProgress.type;
context = consumerType._context;
} else {
context = workInProgress.type;
if (__DEV__) {
if ((context: any)._context !== undefined) {
context = (context: any)._context;
}
}
}
const consumerType: ReactConsumerType<any> = workInProgress.type;
const context: ReactContext<any> = consumerType._context;
const newProps = workInProgress.pendingProps;
const render = newProps.children;

Expand Down Expand Up @@ -3878,12 +3862,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
break;
case ContextProvider: {
const newValue = workInProgress.memoizedProps.value;
let context: ReactContext<any>;
if (enableRenderableContext) {
context = workInProgress.type;
} else {
context = workInProgress.type._context;
}
const context: ReactContext<any> = workInProgress.type;
pushProvider(workInProgress, context, newValue);
break;
}
Expand Down
8 changes: 1 addition & 7 deletions packages/react-reconciler/src/ReactFiberCompleteWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
enablePersistedModeClonedFlag,
enableProfilerTimer,
enableTransitionTracing,
enableRenderableContext,
passChildrenWhenCloningPersistedNodes,
disableLegacyMode,
enableViewTransition,
Expand Down Expand Up @@ -1667,12 +1666,7 @@ function completeWork(
return null;
case ContextProvider:
// Pop provider fiber
let context: ReactContext<any>;
if (enableRenderableContext) {
context = workInProgress.type;
} else {
context = workInProgress.type._context;
}
const context: ReactContext<any> = workInProgress.type;
popProvider(context, workInProgress);
bubbleProperties(workInProgress);
return null;
Expand Down
9 changes: 1 addition & 8 deletions packages/react-reconciler/src/ReactFiberNewContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
} from './ReactFiberFlags';

import is from 'shared/objectIs';
import {enableRenderableContext} from 'shared/ReactFeatureFlags';
import {getHostTransitionProvider} from './ReactFiberHostContext';

const valueCursor: StackCursor<mixed> = createCursor(null);
Expand Down Expand Up @@ -389,13 +388,7 @@ function propagateParentContextChanges(

const oldProps = currentParent.memoizedProps;
if (oldProps !== null) {
let context: ReactContext<any>;
if (enableRenderableContext) {
context = parent.type;
} else {
context = parent.type._context;
}

const context: ReactContext<any> = parent.type;
const newProps = parent.pendingProps;
const newValue = newProps.value;

Expand Down
10 changes: 2 additions & 8 deletions packages/react-reconciler/src/ReactFiberScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ import {
import {isFiberSuspenseAndTimedOut} from './ReactFiberTreeReflection';

import {HostComponent, ScopeComponent, ContextProvider} from './ReactWorkTags';
import {
enableScopeAPI,
enableRenderableContext,
} from 'shared/ReactFeatureFlags';
import {enableScopeAPI} from 'shared/ReactFeatureFlags';

function getSuspenseFallbackChild(fiber: Fiber): Fiber | null {
return ((((fiber.child: any): Fiber).sibling: any): Fiber).child;
Expand Down Expand Up @@ -116,10 +113,7 @@ function collectNearestContextValues<T>(
context: ReactContext<T>,
childContextValues: Array<T>,
): void {
if (
node.tag === ContextProvider &&
(enableRenderableContext ? node.type : node.type._context) === context
) {
if (node.tag === ContextProvider && node.type === context) {
const contextValue = node.memoizedProps.value;
childContextValues.push(contextValue);
} else {
Expand Down
15 changes: 2 additions & 13 deletions packages/react-reconciler/src/ReactFiberUnwindWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {NoMode, ProfileMode} from './ReactTypeOfMode';
import {
enableProfilerTimer,
enableTransitionTracing,
enableRenderableContext,
} from 'shared/ReactFeatureFlags';

import {popHostContainer, popHostContext} from './ReactFiberHostContext';
Expand Down Expand Up @@ -189,12 +188,7 @@ function unwindWork(
popHostContainer(workInProgress);
return null;
case ContextProvider:
let context: ReactContext<any>;
if (enableRenderableContext) {
context = workInProgress.type;
} else {
context = workInProgress.type._context;
}
const context: ReactContext<any> = workInProgress.type;
popProvider(context, workInProgress);
return null;
case OffscreenComponent:
Expand Down Expand Up @@ -286,12 +280,7 @@ function unwindInterruptedWork(
popSuspenseListContext(interruptedWork);
break;
case ContextProvider:
let context: ReactContext<any>;
if (enableRenderableContext) {
context = interruptedWork.type;
} else {
context = interruptedWork.type._context;
}
const context: ReactContext<any> = interruptedWork.type;
popProvider(context, interruptedWork);
break;
case OffscreenComponent:
Expand Down
Loading
Loading