@samitouri / QOS-React-1 / commits / 6946ebe620

Cleanup enableServerComponentKeys flag (#28743)

Cleanup enableServerComponentKeys flag Flag is `true` everywhere but RN where it doesn't apply.

Jan Kassens committed May 8, 2024 at 10:52 UTC 6946ebe620845a0d18e912c9e7ccd4baa0964f1c
9 files changed +5 -30
packages/react-client/src/__tests__/ReactFlight-test.js
-4
@@ -1694,7 +1694,6 @@ describe('ReactFlight', () => {
1694 expect(errors).toEqual([]);
1695 });
1696
1697 - // @gate enableServerComponentKeys
1697 it('preserves state when keying a server component', async () => {
1698 function StatefulClient({name}) {
1699 const [state] = React.useState(name.toLowerCase());
@@ -1751,7 +1750,6 @@ describe('ReactFlight', () => {
1750 );
1751 });
1752
1754 - // @gate enableServerComponentKeys
1753 it('does not inherit keys of children inside a server component', async () => {
1754 function StatefulClient({name, initial}) {
1755 const [state] = React.useState(initial);
@@ -1824,7 +1822,6 @@ describe('ReactFlight', () => {
1822 );
1823 });
1824
1827 - // @gate enableServerComponentKeys
1825 it('shares state between single return and array return in a parent', async () => {
1826 function StatefulClient({name, initial}) {
1827 const [state] = React.useState(initial);
@@ -2065,7 +2062,6 @@ describe('ReactFlight', () => {
2062 );
2063 });
2064
2068 - // @gate enableServerComponentKeys
2065 it('preserves state with keys split across async work', async () => {
2066 let resolve;
2067 const promise = new Promise(r => (resolve = r));
packages/react-server/src/ReactFlightServer.js
+5 -17
@@ -15,7 +15,6 @@ import {
15 enableBinaryFlight,
16 enablePostpone,
17 enableTaint,
18 - enableServerComponentKeys,
18 enableRefAsProp,
19 enableServerComponentLogs,
20 } from 'shared/ReactFeatureFlags';
@@ -993,7 +992,7 @@ function renderFragment(
992 task: Task,
993 children: $ReadOnlyArray<ReactClientValue>,
994 ): ReactJSONValue {
996 - if (enableServerComponentKeys && task.keyPath !== null) {
995 + if (task.keyPath !== null) {
996 // We have a Server Component that specifies a key but we're now splitting
997 // the tree using a fragment.
998 const fragment = [
@@ -1052,7 +1051,7 @@ function renderAsyncFragment(
1051 children: $AsyncIterable<ReactClientValue, ReactClientValue, void>,
1052 getAsyncIterator: () => $AsyncIterator<any, any, any>,
1053 ): ReactJSONValue {
1055 - if (enableServerComponentKeys && task.keyPath !== null) {
1054 + if (task.keyPath !== null) {
1055 // We have a Server Component that specifies a key but we're now splitting
1056 // the tree using a fragment.
1057 const fragment = [
@@ -1095,11 +1094,6 @@ function renderClientElement(
1094 props: any,
1095 owner: null | ReactComponentInfo, // DEV-only
1096 ): ReactJSONValue {
1098 - if (!enableServerComponentKeys) {
1099 - return __DEV__
1100 - ? [REACT_ELEMENT_TYPE, type, key, props, owner]
1101 - : [REACT_ELEMENT_TYPE, type, key, props];
1102 - }
1097 // We prepend the terminal client element that actually gets serialized with
1098 // the keys of any Server Components which are not serialized.
1099 const keyPath = task.keyPath;
@@ -1266,7 +1260,7 @@ function createTask(
1260 if (typeof model === 'object' && model !== null) {
1261 // If we're about to write this into a new task we can assign it an ID early so that
1262 // any other references can refer to the value we're about to write.
1269 - if (enableServerComponentKeys && (keyPath !== null || implicitSlot)) {
1263 + if (keyPath !== null || implicitSlot) {
1264 // If we're in some kind of context we can't necessarily reuse this object depending
1265 // what parent components are used.
1266 } else {
@@ -1756,10 +1750,7 @@ function renderModelDestructive(
1750 const writtenObjects = request.writtenObjects;
1751 const existingId = writtenObjects.get(value);
1752 if (existingId !== undefined) {
1759 - if (
1760 - enableServerComponentKeys &&
1761 - (task.keyPath !== null || task.implicitSlot)
1762 - ) {
1753 + if (task.keyPath !== null || task.implicitSlot) {
1754 // If we're in some kind of context we can't reuse the result of this render or
1755 // previous renders of this element. We only reuse elements if they're not wrapped
1756 // by another Server Component.
@@ -1889,10 +1880,7 @@ function renderModelDestructive(
1880 // $FlowFixMe[method-unbinding]
1881 if (typeof value.then === 'function') {
1882 if (existingId !== undefined) {
1892 - if (
1893 - enableServerComponentKeys &&
1894 - (task.keyPath !== null || task.implicitSlot)
1895 - ) {
1883 + if (task.keyPath !== null || task.implicitSlot) {
1884 // If we're in some kind of context we can't reuse the result of this render or
1885 // previous renders of this element. We only reuse Promises if they're not wrapped
1886 // by another Server Component.
packages/shared/ReactFeatureFlags.js
-3
@@ -169,9 +169,6 @@ export const enableFilterEmptyStringAttributesDOM = true;
169 // Disabled caching behavior of `react/cache` in client runtimes.
170 export const disableClientCache = true;
171
172 -// Changes Server Components Reconciliation when they have keys
173 -export const enableServerComponentKeys = true;
174 -
172 /**
173 * Enables a new error detection for infinite render loops from updates caused
174 * by setState or similar outside of the component owning the state.
packages/shared/forks/ReactFeatureFlags.native-fb.js
-1
@@ -94,7 +94,6 @@ export const enableFizzExternalRuntime = true;
94 export const enableUseDeferredValueInitialArg = true;
95 export const disableClientCache = true;
96
97 -export const enableServerComponentKeys = true;
97 export const enableServerComponentLogs = true;
98
99 export const enableReactTestRendererWarning = false;
packages/shared/forks/ReactFeatureFlags.native-oss.js
-1
@@ -54,7 +54,6 @@ export const enableUnifiedSyncLane = __NEXT_RN_MAJOR__;
54 export const enableFizzExternalRuntime = __NEXT_RN_MAJOR__; // DOM-only
55 export const enableBinaryFlight = __NEXT_RN_MAJOR__; // DOM-only
56 export const enableFlightReadableStream = __NEXT_RN_MAJOR__; // DOM-only
57 -export const enableServerComponentKeys = __NEXT_RN_MAJOR__;
57 export const enableServerComponentLogs = __NEXT_RN_MAJOR__;
58
59 // DEV-only but enabled in the next RN Major.
packages/shared/forks/ReactFeatureFlags.test-renderer.js
-1
@@ -74,7 +74,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
74 export const enableUseDeferredValueInitialArg = __EXPERIMENTAL__;
75 export const disableClientCache = true;
76
77 -export const enableServerComponentKeys = true;
77 export const enableServerComponentLogs = true;
78 export const enableInfiniteRenderLoopDetection = false;
79 export const enableEarlyReturnForPropDiffing = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.native-fb.js
-1
@@ -77,7 +77,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
77 export const enableUseDeferredValueInitialArg = __EXPERIMENTAL__;
78 export const disableClientCache = true;
79
80 -export const enableServerComponentKeys = true;
80 export const enableServerComponentLogs = true;
81
82 export const enableRefAsProp = true;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
-1
@@ -76,7 +76,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
76 export const enableUseDeferredValueInitialArg = true;
77 export const disableClientCache = true;
78
79 -export const enableServerComponentKeys = true;
79 export const enableServerComponentLogs = true;
80 export const enableInfiniteRenderLoopDetection = false;
81
packages/shared/forks/ReactFeatureFlags.www.js
-1
@@ -109,7 +109,6 @@ export const passChildrenWhenCloningPersistedNodes = false;
109 export const enableAsyncDebugInfo = false;
110 export const disableClientCache = true;
111
112 -export const enableServerComponentKeys = true;
112 export const enableServerComponentLogs = true;
113
114 export const enableReactTestRendererWarning = false;