Skip to content

Commit 229c86a

Browse files
authored
Revert "Land enableClientRenderFallbackOnTextMismatch" (#24738)
This reverts commit 327e4a1. Turns out we hadn't rolled this out internally yet — I mistook enableClientRenderFallbackOnHydrationMismatch for said enableClientRenderFallbackOnTextMismatch. Need to revert until we finish rolling out the change.
1 parent c3d7a7e commit 229c86a

15 files changed

+51
-8
lines changed

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

+11-5
Original file line numberDiff line numberDiff line change
@@ -3497,6 +3497,7 @@ describe('ReactDOMFizzServer', () => {
34973497
);
34983498
});
34993499

3500+
// @gate enableClientRenderFallbackOnTextMismatch
35003501
it('#24384: Suspending should halt hydration warnings but still emit hydration warnings after unsuspending if mismatches are genuine', async () => {
35013502
const makeApp = () => {
35023503
let resolve, resolved;
@@ -3586,6 +3587,7 @@ describe('ReactDOMFizzServer', () => {
35863587
expect(Scheduler).toFlushAndYield([]);
35873588
});
35883589

3590+
// @gate enableClientRenderFallbackOnTextMismatch
35893591
it('only warns once on hydration mismatch while within a suspense boundary', async () => {
35903592
const originalConsoleError = console.error;
35913593
const mockError = jest.fn();
@@ -4661,11 +4663,15 @@ describe('ReactDOMFizzServer', () => {
46614663
},
46624664
});
46634665
expect(Scheduler).toFlushAndYield([]);
4664-
expect(errors).toEqual([
4665-
'Text content does not match server-rendered HTML.',
4666-
'Hydration failed because the initial UI does not match what was rendered on the server.',
4667-
'There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.',
4668-
]);
4666+
expect(errors).toEqual(
4667+
[
4668+
gate(flags => flags.enableClientRenderFallbackOnTextMismatch)
4669+
? 'Text content does not match server-rendered HTML.'
4670+
: null,
4671+
'Hydration failed because the initial UI does not match what was rendered on the server.',
4672+
'There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.',
4673+
].filter(Boolean),
4674+
);
46694675
expect(getVisibleChildren(container)).toEqual(
46704676
<title>{['hello1', 'hello2']}</title>,
46714677
);

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

+23-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ describe('ReactDOMServerHydration', () => {
8686
</div>
8787
);
8888
}
89-
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
89+
if (gate(flags => flags.enableClientRenderFallbackOnTextMismatch)) {
90+
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
9091
Array [
9192
"Warning: Text content did not match. Server: \\"server\\" Client: \\"client\\"
9293
in main (at **)
@@ -97,6 +98,16 @@ describe('ReactDOMServerHydration', () => {
9798
"Caught [There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.]",
9899
]
99100
`);
101+
} else {
102+
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
103+
Array [
104+
"Warning: Text content did not match. Server: \\"server\\" Client: \\"client\\"
105+
in main (at **)
106+
in div (at **)
107+
in Mismatch (at **)",
108+
]
109+
`);
110+
}
100111
});
101112

102113
// @gate __DEV__
@@ -346,7 +357,8 @@ describe('ReactDOMServerHydration', () => {
346357
function Mismatch({isClient}) {
347358
return <div className="parent">{isClient && 'only'}</div>;
348359
}
349-
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
360+
if (gate(flags => flags.enableClientRenderFallbackOnTextMismatch)) {
361+
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
350362
Array [
351363
"Warning: Text content did not match. Server: \\"\\" Client: \\"only\\"
352364
in div (at **)
@@ -356,6 +368,15 @@ describe('ReactDOMServerHydration', () => {
356368
"Caught [There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.]",
357369
]
358370
`);
371+
} else {
372+
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
373+
Array [
374+
"Warning: Text content did not match. Server: \\"\\" Client: \\"only\\"
375+
in div (at **)
376+
in Mismatch (at **)",
377+
]
378+
`);
379+
}
359380
});
360381

361382
// @gate __DEV__

packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js

+2
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,7 @@ describe('ReactDOMServerPartialHydration', () => {
34163416
);
34173417
});
34183418

3419+
// @gate enableClientRenderFallbackOnTextMismatch
34193420
it("falls back to client rendering when there's a text mismatch (direct text child)", async () => {
34203421
function DirectTextChild({text}) {
34213422
return <div>{text}</div>;
@@ -3447,6 +3448,7 @@ describe('ReactDOMServerPartialHydration', () => {
34473448
]);
34483449
});
34493450

3451+
// @gate enableClientRenderFallbackOnTextMismatch
34503452
it("falls back to client rendering when there's a text mismatch (text child with siblings)", async () => {
34513453
function Sibling() {
34523454
return 'Sibling';

packages/react-dom/src/client/ReactDOMComponent.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {validateProperties as validateUnknownProperties} from '../shared/ReactDO
7272
import {
7373
enableTrustedTypesIntegration,
7474
enableCustomElementPropertySupport,
75+
enableClientRenderFallbackOnTextMismatch,
7576
} from 'shared/ReactFeatureFlags';
7677
import {
7778
mediaEventTypes,
@@ -249,7 +250,7 @@ export function checkForUnmatchedText(
249250
}
250251
}
251252

252-
if (isConcurrentMode) {
253+
if (isConcurrentMode && enableClientRenderFallbackOnTextMismatch) {
253254
// In concurrent roots, we throw when there's a text mismatch and revert to
254255
// client rendering, up to the nearest Suspense boundary.
255256
throw new Error('Text content does not match server-rendered HTML.');

packages/react-reconciler/src/__tests__/useMutableSourceHydration-test.js

+1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ describe('useMutableSourceHydration', () => {
169169
});
170170

171171
// @gate enableUseMutableSource
172+
// @gate enableClientRenderFallbackOnTextMismatch
172173
it('should detect a tear before hydrating a component', () => {
173174
const source = createSource('one');
174175
const mutableSource = createMutableSource(source, param => param.version);

packages/shared/ReactFeatureFlags.js

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export const enableSymbolFallbackForWWW = false;
3131
// internal tests need to be updated. The open source behavior is correct.
3232
export const skipUnmountedBoundaries = true;
3333

34+
// TODO: Finish rolling out in www
35+
export const enableClientRenderFallbackOnTextMismatch = true;
36+
3437
// TODO: Need to review this code one more time before landing
3538
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
3639

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

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const enableSuspenseAvoidThisFallback = false;
5151
export const enableSuspenseAvoidThisFallbackFizz = false;
5252
export const enableCPUSuspense = true;
5353
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
54+
export const enableClientRenderFallbackOnTextMismatch = true;
5455
export const enableComponentStackLocations = false;
5556
export const enableLegacyFBSupport = false;
5657
export const enableFilterEmptyStringAttributesDOM = false;

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

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const enableSuspenseAvoidThisFallback = false;
4141
export const enableSuspenseAvoidThisFallbackFizz = false;
4242
export const enableCPUSuspense = false;
4343
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
44+
export const enableClientRenderFallbackOnTextMismatch = true;
4445
export const enableComponentStackLocations = false;
4546
export const enableLegacyFBSupport = false;
4647
export const enableFilterEmptyStringAttributesDOM = false;

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

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const enableSuspenseAvoidThisFallback = false;
4141
export const enableSuspenseAvoidThisFallbackFizz = false;
4242
export const enableCPUSuspense = false;
4343
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
44+
export const enableClientRenderFallbackOnTextMismatch = true;
4445
export const enableComponentStackLocations = true;
4546
export const enableLegacyFBSupport = false;
4647
export const enableFilterEmptyStringAttributesDOM = false;

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

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const enableSuspenseAvoidThisFallback = false;
5050
export const enableSuspenseAvoidThisFallbackFizz = false;
5151
export const enableCPUSuspense = false;
5252
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
53+
export const enableClientRenderFallbackOnTextMismatch = true;
5354
export const enableStrictEffects = false;
5455
export const createRootStrictEffectsByDefault = false;
5556
export const enableUseRefAccessWarning = false;

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

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const enableSuspenseAvoidThisFallback = true;
4141
export const enableSuspenseAvoidThisFallbackFizz = false;
4242
export const enableCPUSuspense = false;
4343
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
44+
export const enableClientRenderFallbackOnTextMismatch = true;
4445
export const enableComponentStackLocations = true;
4546
export const enableLegacyFBSupport = false;
4647
export const enableFilterEmptyStringAttributesDOM = false;

packages/shared/forks/ReactFeatureFlags.testing.js

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const enableSuspenseAvoidThisFallback = false;
4141
export const enableSuspenseAvoidThisFallbackFizz = false;
4242
export const enableCPUSuspense = false;
4343
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
44+
export const enableClientRenderFallbackOnTextMismatch = true;
4445
export const enableComponentStackLocations = true;
4546
export const enableLegacyFBSupport = false;
4647
export const enableFilterEmptyStringAttributesDOM = false;

packages/shared/forks/ReactFeatureFlags.testing.www.js

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const enableSuspenseAvoidThisFallback = true;
4141
export const enableSuspenseAvoidThisFallbackFizz = false;
4242
export const enableCPUSuspense = true;
4343
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
44+
export const enableClientRenderFallbackOnTextMismatch = true;
4445
export const enableComponentStackLocations = true;
4546
export const enableLegacyFBSupport = !__EXPERIMENTAL__;
4647
export const enableFilterEmptyStringAttributesDOM = false;

packages/shared/forks/ReactFeatureFlags.www-dynamic.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const enableLazyContextPropagation = __VARIANT__;
2626
export const enableSyncDefaultUpdates = __VARIANT__;
2727
export const consoleManagedByDevToolsDuringStrictMode = __VARIANT__;
2828
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = __VARIANT__;
29+
export const enableClientRenderFallbackOnTextMismatch = __VARIANT__;
2930
export const enableTransitionTracing = __VARIANT__;
3031
export const enableSymbolFallbackForWWW = __VARIANT__;
3132
// Enable this flag to help with concurrent mode debugging.

packages/shared/forks/ReactFeatureFlags.www.js

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const {
3232
enableLazyContextPropagation,
3333
enableSyncDefaultUpdates,
3434
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
35+
enableClientRenderFallbackOnTextMismatch,
3536
} = dynamicFeatureFlags;
3637

3738
// On WWW, __EXPERIMENTAL__ is used for a new modern build.

0 commit comments

Comments
 (0)