Skip to content

Commit 6946ebe

Browse files
authored
Cleanup enableServerComponentKeys flag (#28743)
Cleanup enableServerComponentKeys flag Flag is `true` everywhere but RN where it doesn't apply.
1 parent 1717ab0 commit 6946ebe

9 files changed

+5
-30
lines changed

packages/react-client/src/__tests__/ReactFlight-test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,6 @@ describe('ReactFlight', () => {
16941694
expect(errors).toEqual([]);
16951695
});
16961696

1697-
// @gate enableServerComponentKeys
16981697
it('preserves state when keying a server component', async () => {
16991698
function StatefulClient({name}) {
17001699
const [state] = React.useState(name.toLowerCase());
@@ -1751,7 +1750,6 @@ describe('ReactFlight', () => {
17511750
);
17521751
});
17531752

1754-
// @gate enableServerComponentKeys
17551753
it('does not inherit keys of children inside a server component', async () => {
17561754
function StatefulClient({name, initial}) {
17571755
const [state] = React.useState(initial);
@@ -1824,7 +1822,6 @@ describe('ReactFlight', () => {
18241822
);
18251823
});
18261824

1827-
// @gate enableServerComponentKeys
18281825
it('shares state between single return and array return in a parent', async () => {
18291826
function StatefulClient({name, initial}) {
18301827
const [state] = React.useState(initial);
@@ -2065,7 +2062,6 @@ describe('ReactFlight', () => {
20652062
);
20662063
});
20672064

2068-
// @gate enableServerComponentKeys
20692065
it('preserves state with keys split across async work', async () => {
20702066
let resolve;
20712067
const promise = new Promise(r => (resolve = r));

packages/react-server/src/ReactFlightServer.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
enableBinaryFlight,
1616
enablePostpone,
1717
enableTaint,
18-
enableServerComponentKeys,
1918
enableRefAsProp,
2019
enableServerComponentLogs,
2120
} from 'shared/ReactFeatureFlags';
@@ -993,7 +992,7 @@ function renderFragment(
993992
task: Task,
994993
children: $ReadOnlyArray<ReactClientValue>,
995994
): ReactJSONValue {
996-
if (enableServerComponentKeys && task.keyPath !== null) {
995+
if (task.keyPath !== null) {
997996
// We have a Server Component that specifies a key but we're now splitting
998997
// the tree using a fragment.
999998
const fragment = [
@@ -1052,7 +1051,7 @@ function renderAsyncFragment(
10521051
children: $AsyncIterable<ReactClientValue, ReactClientValue, void>,
10531052
getAsyncIterator: () => $AsyncIterator<any, any, any>,
10541053
): ReactJSONValue {
1055-
if (enableServerComponentKeys && task.keyPath !== null) {
1054+
if (task.keyPath !== null) {
10561055
// We have a Server Component that specifies a key but we're now splitting
10571056
// the tree using a fragment.
10581057
const fragment = [
@@ -1095,11 +1094,6 @@ function renderClientElement(
10951094
props: any,
10961095
owner: null | ReactComponentInfo, // DEV-only
10971096
): ReactJSONValue {
1098-
if (!enableServerComponentKeys) {
1099-
return __DEV__
1100-
? [REACT_ELEMENT_TYPE, type, key, props, owner]
1101-
: [REACT_ELEMENT_TYPE, type, key, props];
1102-
}
11031097
// We prepend the terminal client element that actually gets serialized with
11041098
// the keys of any Server Components which are not serialized.
11051099
const keyPath = task.keyPath;
@@ -1266,7 +1260,7 @@ function createTask(
12661260
if (typeof model === 'object' && model !== null) {
12671261
// If we're about to write this into a new task we can assign it an ID early so that
12681262
// any other references can refer to the value we're about to write.
1269-
if (enableServerComponentKeys && (keyPath !== null || implicitSlot)) {
1263+
if (keyPath !== null || implicitSlot) {
12701264
// If we're in some kind of context we can't necessarily reuse this object depending
12711265
// what parent components are used.
12721266
} else {
@@ -1756,10 +1750,7 @@ function renderModelDestructive(
17561750
const writtenObjects = request.writtenObjects;
17571751
const existingId = writtenObjects.get(value);
17581752
if (existingId !== undefined) {
1759-
if (
1760-
enableServerComponentKeys &&
1761-
(task.keyPath !== null || task.implicitSlot)
1762-
) {
1753+
if (task.keyPath !== null || task.implicitSlot) {
17631754
// If we're in some kind of context we can't reuse the result of this render or
17641755
// previous renders of this element. We only reuse elements if they're not wrapped
17651756
// by another Server Component.
@@ -1889,10 +1880,7 @@ function renderModelDestructive(
18891880
// $FlowFixMe[method-unbinding]
18901881
if (typeof value.then === 'function') {
18911882
if (existingId !== undefined) {
1892-
if (
1893-
enableServerComponentKeys &&
1894-
(task.keyPath !== null || task.implicitSlot)
1895-
) {
1883+
if (task.keyPath !== null || task.implicitSlot) {
18961884
// If we're in some kind of context we can't reuse the result of this render or
18971885
// previous renders of this element. We only reuse Promises if they're not wrapped
18981886
// by another Server Component.

packages/shared/ReactFeatureFlags.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,6 @@ export const enableFilterEmptyStringAttributesDOM = true;
169169
// Disabled caching behavior of `react/cache` in client runtimes.
170170
export const disableClientCache = true;
171171

172-
// Changes Server Components Reconciliation when they have keys
173-
export const enableServerComponentKeys = true;
174-
175172
/**
176173
* Enables a new error detection for infinite render loops from updates caused
177174
* by setState or similar outside of the component owning the state.

packages/shared/forks/ReactFeatureFlags.native-fb.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export const enableFizzExternalRuntime = true;
9494
export const enableUseDeferredValueInitialArg = true;
9595
export const disableClientCache = true;
9696

97-
export const enableServerComponentKeys = true;
9897
export const enableServerComponentLogs = true;
9998

10099
export const enableReactTestRendererWarning = false;

packages/shared/forks/ReactFeatureFlags.native-oss.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const enableUnifiedSyncLane = __NEXT_RN_MAJOR__;
5454
export const enableFizzExternalRuntime = __NEXT_RN_MAJOR__; // DOM-only
5555
export const enableBinaryFlight = __NEXT_RN_MAJOR__; // DOM-only
5656
export const enableFlightReadableStream = __NEXT_RN_MAJOR__; // DOM-only
57-
export const enableServerComponentKeys = __NEXT_RN_MAJOR__;
5857
export const enableServerComponentLogs = __NEXT_RN_MAJOR__;
5958

6059
// DEV-only but enabled in the next RN Major.

packages/shared/forks/ReactFeatureFlags.test-renderer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
7474
export const enableUseDeferredValueInitialArg = __EXPERIMENTAL__;
7575
export const disableClientCache = true;
7676

77-
export const enableServerComponentKeys = true;
7877
export const enableServerComponentLogs = true;
7978
export const enableInfiniteRenderLoopDetection = false;
8079
export const enableEarlyReturnForPropDiffing = false;

packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
7777
export const enableUseDeferredValueInitialArg = __EXPERIMENTAL__;
7878
export const disableClientCache = true;
7979

80-
export const enableServerComponentKeys = true;
8180
export const enableServerComponentLogs = true;
8281

8382
export const enableRefAsProp = true;

packages/shared/forks/ReactFeatureFlags.test-renderer.www.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
7676
export const enableUseDeferredValueInitialArg = true;
7777
export const disableClientCache = true;
7878

79-
export const enableServerComponentKeys = true;
8079
export const enableServerComponentLogs = true;
8180
export const enableInfiniteRenderLoopDetection = false;
8281

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
109109
export const enableAsyncDebugInfo = false;
110110
export const disableClientCache = true;
111111

112-
export const enableServerComponentKeys = true;
113112
export const enableServerComponentLogs = true;
114113

115114
export const enableReactTestRendererWarning = false;

0 commit comments

Comments
 (0)