Skip to content

Commit 3228a86

Browse files
committed
Remove feature flag enableRenderableContext
The flag is fully rolled out.
1 parent 56408a5 commit 3228a86

27 files changed

+48
-292
lines changed

packages/react-client/src/ReactFlightReplyClient.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ import type {
1818
import type {LazyComponent} from 'react/src/ReactLazy';
1919
import type {TemporaryReferenceSet} from './ReactFlightTemporaryReferences';
2020

21-
import {enableRenderableContext} from 'shared/ReactFeatureFlags';
22-
2321
import {
2422
REACT_ELEMENT_TYPE,
2523
REACT_LAZY_TYPE,
2624
REACT_CONTEXT_TYPE,
27-
REACT_PROVIDER_TYPE,
2825
getIteratorFn,
2926
ASYNC_ITERATOR,
3027
} from 'shared/ReactSymbols';
@@ -699,10 +696,7 @@ export function processReply(
699696
return serializeTemporaryReferenceMarker();
700697
}
701698
if (__DEV__) {
702-
if (
703-
(value: any).$$typeof ===
704-
(enableRenderableContext ? REACT_CONTEXT_TYPE : REACT_PROVIDER_TYPE)
705-
) {
699+
if ((value: any).$$typeof === REACT_CONTEXT_TYPE) {
706700
console.error(
707701
'React Context Providers cannot be passed to Server Functions from the Client.%s',
708702
describeObjectForErrorMessage(parent, key),

packages/react-devtools-shared/src/utils.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ import {
1919
REACT_MEMO_TYPE,
2020
REACT_PORTAL_TYPE,
2121
REACT_PROFILER_TYPE,
22-
REACT_PROVIDER_TYPE,
2322
REACT_STRICT_MODE_TYPE,
2423
REACT_SUSPENSE_LIST_TYPE,
2524
REACT_SUSPENSE_TYPE,
2625
REACT_TRACING_MARKER_TYPE,
2726
REACT_VIEW_TRANSITION_TYPE,
2827
} from 'shared/ReactSymbols';
29-
import {enableRenderableContext} from 'shared/ReactFeatureFlags';
3028
import {
3129
TREE_OPERATION_ADD,
3230
TREE_OPERATION_REMOVE,
@@ -87,6 +85,9 @@ const encodedStringCache: LRUCache<string, Array<number>> = new LRU({
8785
max: 1000,
8886
});
8987

88+
// Previously, the type of `Context.Provider`.
89+
const LEGACY_REACT_PROVIDER_TYPE: symbol = Symbol.for('react.provider');
90+
9091
export function alphaSortKeys(
9192
a: string | number | symbol,
9293
b: string | number | symbol,
@@ -712,14 +713,7 @@ function typeOfWithLegacyElementSymbol(object: any): mixed {
712713
case REACT_MEMO_TYPE:
713714
return $$typeofType;
714715
case REACT_CONSUMER_TYPE:
715-
if (enableRenderableContext) {
716-
return $$typeofType;
717-
}
718-
// Fall through
719-
case REACT_PROVIDER_TYPE:
720-
if (!enableRenderableContext) {
721-
return $$typeofType;
722-
}
716+
return $$typeofType;
723717
// Fall through
724718
default:
725719
return $$typeof;
@@ -740,7 +734,7 @@ export function getDisplayNameForReactElement(
740734
switch (elementType) {
741735
case REACT_CONSUMER_TYPE:
742736
return 'ContextConsumer';
743-
case REACT_PROVIDER_TYPE:
737+
case LEGACY_REACT_PROVIDER_TYPE:
744738
return 'ContextProvider';
745739
case REACT_CONTEXT_TYPE:
746740
return 'Context';

packages/react-dom/src/__tests__/ReactDOMServerIntegrationNewContext-test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,6 @@ describe('ReactDOMServerIntegration', () => {
295295
});
296296

297297
itRenders('should treat Context as Context.Provider', async render => {
298-
// The `itRenders` helpers don't work with the gate pragma, so we have to do
299-
// this instead.
300-
if (gate(flags => !flags.enableRenderableContext)) {
301-
return;
302-
}
303-
304298
const Theme = React.createContext('dark');
305299
const Language = React.createContext('french');
306300

packages/react-dom/src/__tests__/ReactServerRendering-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,6 @@ describe('ReactDOMServer', () => {
932932
]);
933933
});
934934

935-
// @gate enableRenderableContext || !__DEV__
936935
it('should warn if an invalid contextType is defined', () => {
937936
const Context = React.createContext();
938937
class ComponentA extends React.Component {

packages/react-is/src/ReactIs.js

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
REACT_MEMO_TYPE,
1919
REACT_PORTAL_TYPE,
2020
REACT_PROFILER_TYPE,
21-
REACT_PROVIDER_TYPE,
2221
REACT_CONSUMER_TYPE,
2322
REACT_STRICT_MODE_TYPE,
2423
REACT_SUSPENSE_TYPE,
@@ -30,7 +29,6 @@ import {
3029
} from 'shared/ReactSymbols';
3130

3231
import {
33-
enableRenderableContext,
3432
enableScopeAPI,
3533
enableTransitionTracing,
3634
enableLegacyHidden,
@@ -64,14 +62,7 @@ export function typeOf(object: any): mixed {
6462
case REACT_MEMO_TYPE:
6563
return $$typeofType;
6664
case REACT_CONSUMER_TYPE:
67-
if (enableRenderableContext) {
68-
return $$typeofType;
69-
}
70-
// Fall through
71-
case REACT_PROVIDER_TYPE:
72-
if (!enableRenderableContext) {
73-
return $$typeofType;
74-
}
65+
return $$typeofType;
7566
// Fall through
7667
default:
7768
return $$typeof;
@@ -85,12 +76,8 @@ export function typeOf(object: any): mixed {
8576
return undefined;
8677
}
8778

88-
export const ContextConsumer: symbol = enableRenderableContext
89-
? REACT_CONSUMER_TYPE
90-
: REACT_CONTEXT_TYPE;
91-
export const ContextProvider: symbol = enableRenderableContext
92-
? REACT_CONTEXT_TYPE
93-
: REACT_PROVIDER_TYPE;
79+
export const ContextConsumer: symbol = REACT_CONSUMER_TYPE;
80+
export const ContextProvider: symbol = REACT_CONTEXT_TYPE;
9481
export const Element = REACT_ELEMENT_TYPE;
9582
export const ForwardRef = REACT_FORWARD_REF_TYPE;
9683
export const Fragment = REACT_FRAGMENT_TYPE;
@@ -127,8 +114,7 @@ export function isValidElementType(type: mixed): boolean {
127114
type.$$typeof === REACT_LAZY_TYPE ||
128115
type.$$typeof === REACT_MEMO_TYPE ||
129116
type.$$typeof === REACT_CONTEXT_TYPE ||
130-
(!enableRenderableContext && type.$$typeof === REACT_PROVIDER_TYPE) ||
131-
(enableRenderableContext && type.$$typeof === REACT_CONSUMER_TYPE) ||
117+
type.$$typeof === REACT_CONSUMER_TYPE ||
132118
type.$$typeof === REACT_FORWARD_REF_TYPE ||
133119
// This needs to include all possible module reference object
134120
// types supported by any Flight configuration anywhere since
@@ -145,18 +131,10 @@ export function isValidElementType(type: mixed): boolean {
145131
}
146132

147133
export function isContextConsumer(object: any): boolean {
148-
if (enableRenderableContext) {
149-
return typeOf(object) === REACT_CONSUMER_TYPE;
150-
} else {
151-
return typeOf(object) === REACT_CONTEXT_TYPE;
152-
}
134+
return typeOf(object) === REACT_CONSUMER_TYPE;
153135
}
154136
export function isContextProvider(object: any): boolean {
155-
if (enableRenderableContext) {
156-
return typeOf(object) === REACT_CONTEXT_TYPE;
157-
} else {
158-
return typeOf(object) === REACT_PROVIDER_TYPE;
159-
}
137+
return typeOf(object) === REACT_CONTEXT_TYPE;
160138
}
161139
export function isElement(object: any): boolean {
162140
return (

packages/react-reconciler/src/ReactFiber.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import {
4141
enableLegacyHidden,
4242
enableTransitionTracing,
4343
enableDO_NOT_USE_disableStrictPassiveEffect,
44-
enableRenderableContext,
4544
disableLegacyMode,
4645
enableObjectFiber,
4746
enableViewTransition,
@@ -101,7 +100,6 @@ import {
101100
REACT_FRAGMENT_TYPE,
102101
REACT_STRICT_MODE_TYPE,
103102
REACT_PROFILER_TYPE,
104-
REACT_PROVIDER_TYPE,
105103
REACT_CONTEXT_TYPE,
106104
REACT_CONSUMER_TYPE,
107105
REACT_SUSPENSE_TYPE,
@@ -638,25 +636,12 @@ export function createFiberFromTypeAndProps(
638636
default: {
639637
if (typeof type === 'object' && type !== null) {
640638
switch (type.$$typeof) {
641-
case REACT_PROVIDER_TYPE:
642-
if (!enableRenderableContext) {
643-
fiberTag = ContextProvider;
644-
break getTag;
645-
}
646-
// Fall through
647639
case REACT_CONTEXT_TYPE:
648-
if (enableRenderableContext) {
649-
fiberTag = ContextProvider;
650-
break getTag;
651-
} else {
652-
fiberTag = ContextConsumer;
653-
break getTag;
654-
}
640+
fiberTag = ContextProvider;
641+
break getTag;
655642
case REACT_CONSUMER_TYPE:
656-
if (enableRenderableContext) {
657-
fiberTag = ContextConsumer;
658-
break getTag;
659-
}
643+
fiberTag = ContextConsumer;
644+
break getTag;
660645
// Fall through
661646
case REACT_FORWARD_REF_TYPE:
662647
fiberTag = ForwardRef;

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ import {
116116
enableLegacyHidden,
117117
enableCPUSuspense,
118118
enablePostpone,
119-
enableRenderableContext,
120119
disableLegacyMode,
121120
disableDefaultPropsExceptForClasses,
122121
enableHydrationLaneScheduling,
@@ -3591,12 +3590,7 @@ function updateContextProvider(
35913590
workInProgress: Fiber,
35923591
renderLanes: Lanes,
35933592
) {
3594-
let context: ReactContext<any>;
3595-
if (enableRenderableContext) {
3596-
context = workInProgress.type;
3597-
} else {
3598-
context = workInProgress.type._context;
3599-
}
3593+
const context: ReactContext<any> = workInProgress.type;
36003594
const newProps = workInProgress.pendingProps;
36013595
const newValue = newProps.value;
36023596

@@ -3623,18 +3617,8 @@ function updateContextConsumer(
36233617
workInProgress: Fiber,
36243618
renderLanes: Lanes,
36253619
) {
3626-
let context: ReactContext<any>;
3627-
if (enableRenderableContext) {
3628-
const consumerType: ReactConsumerType<any> = workInProgress.type;
3629-
context = consumerType._context;
3630-
} else {
3631-
context = workInProgress.type;
3632-
if (__DEV__) {
3633-
if ((context: any)._context !== undefined) {
3634-
context = (context: any)._context;
3635-
}
3636-
}
3637-
}
3620+
const consumerType: ReactConsumerType<any> = workInProgress.type;
3621+
const context: ReactContext<any> = consumerType._context;
36383622
const newProps = workInProgress.pendingProps;
36393623
const render = newProps.children;
36403624

@@ -3878,12 +3862,7 @@ function attemptEarlyBailoutIfNoScheduledUpdate(
38783862
break;
38793863
case ContextProvider: {
38803864
const newValue = workInProgress.memoizedProps.value;
3881-
let context: ReactContext<any>;
3882-
if (enableRenderableContext) {
3883-
context = workInProgress.type;
3884-
} else {
3885-
context = workInProgress.type._context;
3886-
}
3865+
const context: ReactContext<any> = workInProgress.type;
38873866
pushProvider(workInProgress, context, newValue);
38883867
break;
38893868
}

packages/react-reconciler/src/ReactFiberCompleteWork.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import {
3838
enablePersistedModeClonedFlag,
3939
enableProfilerTimer,
4040
enableTransitionTracing,
41-
enableRenderableContext,
4241
passChildrenWhenCloningPersistedNodes,
4342
disableLegacyMode,
4443
enableViewTransition,
@@ -1667,12 +1666,7 @@ function completeWork(
16671666
return null;
16681667
case ContextProvider:
16691668
// Pop provider fiber
1670-
let context: ReactContext<any>;
1671-
if (enableRenderableContext) {
1672-
context = workInProgress.type;
1673-
} else {
1674-
context = workInProgress.type._context;
1675-
}
1669+
const context: ReactContext<any> = workInProgress.type;
16761670
popProvider(context, workInProgress);
16771671
bubbleProperties(workInProgress);
16781672
return null;

packages/react-reconciler/src/ReactFiberNewContext.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
} from './ReactFiberFlags';
3030

3131
import is from 'shared/objectIs';
32-
import {enableRenderableContext} from 'shared/ReactFeatureFlags';
3332
import {getHostTransitionProvider} from './ReactFiberHostContext';
3433

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

390389
const oldProps = currentParent.memoizedProps;
391390
if (oldProps !== null) {
392-
let context: ReactContext<any>;
393-
if (enableRenderableContext) {
394-
context = parent.type;
395-
} else {
396-
context = parent.type._context;
397-
}
398-
391+
const context: ReactContext<any> = parent.type;
399392
const newProps = parent.pendingProps;
400393
const newValue = newProps.value;
401394

packages/react-reconciler/src/ReactFiberScope.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ import {
2222
import {isFiberSuspenseAndTimedOut} from './ReactFiberTreeReflection';
2323

2424
import {HostComponent, ScopeComponent, ContextProvider} from './ReactWorkTags';
25-
import {
26-
enableScopeAPI,
27-
enableRenderableContext,
28-
} from 'shared/ReactFeatureFlags';
25+
import {enableScopeAPI} from 'shared/ReactFeatureFlags';
2926

3027
function getSuspenseFallbackChild(fiber: Fiber): Fiber | null {
3128
return ((((fiber.child: any): Fiber).sibling: any): Fiber).child;
@@ -116,10 +113,7 @@ function collectNearestContextValues<T>(
116113
context: ReactContext<T>,
117114
childContextValues: Array<T>,
118115
): void {
119-
if (
120-
node.tag === ContextProvider &&
121-
(enableRenderableContext ? node.type : node.type._context) === context
122-
) {
116+
if (node.tag === ContextProvider && node.type === context) {
123117
const contextValue = node.memoizedProps.value;
124118
childContextValues.push(contextValue);
125119
} else {

0 commit comments

Comments
 (0)