mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Revert "Land enableClientRenderFallbackOnTextMismatch" (#24738)
This reverts commit 327e4a1f96.
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.
This commit is contained in:
@@ -3497,6 +3497,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
);
|
||||
});
|
||||
|
||||
// @gate enableClientRenderFallbackOnTextMismatch
|
||||
it('#24384: Suspending should halt hydration warnings but still emit hydration warnings after unsuspending if mismatches are genuine', async () => {
|
||||
const makeApp = () => {
|
||||
let resolve, resolved;
|
||||
@@ -3586,6 +3587,7 @@ describe('ReactDOMFizzServer', () => {
|
||||
expect(Scheduler).toFlushAndYield([]);
|
||||
});
|
||||
|
||||
// @gate enableClientRenderFallbackOnTextMismatch
|
||||
it('only warns once on hydration mismatch while within a suspense boundary', async () => {
|
||||
const originalConsoleError = console.error;
|
||||
const mockError = jest.fn();
|
||||
@@ -4661,11 +4663,15 @@ describe('ReactDOMFizzServer', () => {
|
||||
},
|
||||
});
|
||||
expect(Scheduler).toFlushAndYield([]);
|
||||
expect(errors).toEqual([
|
||||
'Text content does not match server-rendered HTML.',
|
||||
'Hydration failed because the initial UI does not match what was rendered on the server.',
|
||||
'There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.',
|
||||
]);
|
||||
expect(errors).toEqual(
|
||||
[
|
||||
gate(flags => flags.enableClientRenderFallbackOnTextMismatch)
|
||||
? 'Text content does not match server-rendered HTML.'
|
||||
: null,
|
||||
'Hydration failed because the initial UI does not match what was rendered on the server.',
|
||||
'There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.',
|
||||
].filter(Boolean),
|
||||
);
|
||||
expect(getVisibleChildren(container)).toEqual(
|
||||
<title>{['hello1', 'hello2']}</title>,
|
||||
);
|
||||
|
||||
@@ -86,7 +86,8 @@ describe('ReactDOMServerHydration', () => {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
|
||||
if (gate(flags => flags.enableClientRenderFallbackOnTextMismatch)) {
|
||||
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Warning: Text content did not match. Server: \\"server\\" Client: \\"client\\"
|
||||
in main (at **)
|
||||
@@ -97,6 +98,16 @@ describe('ReactDOMServerHydration', () => {
|
||||
"Caught [There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.]",
|
||||
]
|
||||
`);
|
||||
} else {
|
||||
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Warning: Text content did not match. Server: \\"server\\" Client: \\"client\\"
|
||||
in main (at **)
|
||||
in div (at **)
|
||||
in Mismatch (at **)",
|
||||
]
|
||||
`);
|
||||
}
|
||||
});
|
||||
|
||||
// @gate __DEV__
|
||||
@@ -346,7 +357,8 @@ describe('ReactDOMServerHydration', () => {
|
||||
function Mismatch({isClient}) {
|
||||
return <div className="parent">{isClient && 'only'}</div>;
|
||||
}
|
||||
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
|
||||
if (gate(flags => flags.enableClientRenderFallbackOnTextMismatch)) {
|
||||
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Warning: Text content did not match. Server: \\"\\" Client: \\"only\\"
|
||||
in div (at **)
|
||||
@@ -356,6 +368,15 @@ describe('ReactDOMServerHydration', () => {
|
||||
"Caught [There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.]",
|
||||
]
|
||||
`);
|
||||
} else {
|
||||
expect(testMismatch(Mismatch)).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"Warning: Text content did not match. Server: \\"\\" Client: \\"only\\"
|
||||
in div (at **)
|
||||
in Mismatch (at **)",
|
||||
]
|
||||
`);
|
||||
}
|
||||
});
|
||||
|
||||
// @gate __DEV__
|
||||
|
||||
@@ -3416,6 +3416,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
);
|
||||
});
|
||||
|
||||
// @gate enableClientRenderFallbackOnTextMismatch
|
||||
it("falls back to client rendering when there's a text mismatch (direct text child)", async () => {
|
||||
function DirectTextChild({text}) {
|
||||
return <div>{text}</div>;
|
||||
@@ -3447,6 +3448,7 @@ describe('ReactDOMServerPartialHydration', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
// @gate enableClientRenderFallbackOnTextMismatch
|
||||
it("falls back to client rendering when there's a text mismatch (text child with siblings)", async () => {
|
||||
function Sibling() {
|
||||
return 'Sibling';
|
||||
|
||||
@@ -72,6 +72,7 @@ import {validateProperties as validateUnknownProperties} from '../shared/ReactDO
|
||||
import {
|
||||
enableTrustedTypesIntegration,
|
||||
enableCustomElementPropertySupport,
|
||||
enableClientRenderFallbackOnTextMismatch,
|
||||
} from 'shared/ReactFeatureFlags';
|
||||
import {
|
||||
mediaEventTypes,
|
||||
@@ -249,7 +250,7 @@ export function checkForUnmatchedText(
|
||||
}
|
||||
}
|
||||
|
||||
if (isConcurrentMode) {
|
||||
if (isConcurrentMode && enableClientRenderFallbackOnTextMismatch) {
|
||||
// In concurrent roots, we throw when there's a text mismatch and revert to
|
||||
// client rendering, up to the nearest Suspense boundary.
|
||||
throw new Error('Text content does not match server-rendered HTML.');
|
||||
|
||||
@@ -169,6 +169,7 @@ describe('useMutableSourceHydration', () => {
|
||||
});
|
||||
|
||||
// @gate enableUseMutableSource
|
||||
// @gate enableClientRenderFallbackOnTextMismatch
|
||||
it('should detect a tear before hydrating a component', () => {
|
||||
const source = createSource('one');
|
||||
const mutableSource = createMutableSource(source, param => param.version);
|
||||
|
||||
@@ -31,6 +31,9 @@ export const enableSymbolFallbackForWWW = false;
|
||||
// internal tests need to be updated. The open source behavior is correct.
|
||||
export const skipUnmountedBoundaries = true;
|
||||
|
||||
// TODO: Finish rolling out in www
|
||||
export const enableClientRenderFallbackOnTextMismatch = true;
|
||||
|
||||
// TODO: Need to review this code one more time before landing
|
||||
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ export const enableSuspenseAvoidThisFallback = false;
|
||||
export const enableSuspenseAvoidThisFallbackFizz = false;
|
||||
export const enableCPUSuspense = true;
|
||||
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
|
||||
export const enableClientRenderFallbackOnTextMismatch = true;
|
||||
export const enableComponentStackLocations = false;
|
||||
export const enableLegacyFBSupport = false;
|
||||
export const enableFilterEmptyStringAttributesDOM = false;
|
||||
|
||||
@@ -41,6 +41,7 @@ export const enableSuspenseAvoidThisFallback = false;
|
||||
export const enableSuspenseAvoidThisFallbackFizz = false;
|
||||
export const enableCPUSuspense = false;
|
||||
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
|
||||
export const enableClientRenderFallbackOnTextMismatch = true;
|
||||
export const enableComponentStackLocations = false;
|
||||
export const enableLegacyFBSupport = false;
|
||||
export const enableFilterEmptyStringAttributesDOM = false;
|
||||
|
||||
@@ -41,6 +41,7 @@ export const enableSuspenseAvoidThisFallback = false;
|
||||
export const enableSuspenseAvoidThisFallbackFizz = false;
|
||||
export const enableCPUSuspense = false;
|
||||
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
|
||||
export const enableClientRenderFallbackOnTextMismatch = true;
|
||||
export const enableComponentStackLocations = true;
|
||||
export const enableLegacyFBSupport = false;
|
||||
export const enableFilterEmptyStringAttributesDOM = false;
|
||||
|
||||
@@ -50,6 +50,7 @@ export const enableSuspenseAvoidThisFallback = false;
|
||||
export const enableSuspenseAvoidThisFallbackFizz = false;
|
||||
export const enableCPUSuspense = false;
|
||||
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
|
||||
export const enableClientRenderFallbackOnTextMismatch = true;
|
||||
export const enableStrictEffects = false;
|
||||
export const createRootStrictEffectsByDefault = false;
|
||||
export const enableUseRefAccessWarning = false;
|
||||
|
||||
@@ -41,6 +41,7 @@ export const enableSuspenseAvoidThisFallback = true;
|
||||
export const enableSuspenseAvoidThisFallbackFizz = false;
|
||||
export const enableCPUSuspense = false;
|
||||
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
|
||||
export const enableClientRenderFallbackOnTextMismatch = true;
|
||||
export const enableComponentStackLocations = true;
|
||||
export const enableLegacyFBSupport = false;
|
||||
export const enableFilterEmptyStringAttributesDOM = false;
|
||||
|
||||
@@ -41,6 +41,7 @@ export const enableSuspenseAvoidThisFallback = false;
|
||||
export const enableSuspenseAvoidThisFallbackFizz = false;
|
||||
export const enableCPUSuspense = false;
|
||||
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
|
||||
export const enableClientRenderFallbackOnTextMismatch = true;
|
||||
export const enableComponentStackLocations = true;
|
||||
export const enableLegacyFBSupport = false;
|
||||
export const enableFilterEmptyStringAttributesDOM = false;
|
||||
|
||||
@@ -41,6 +41,7 @@ export const enableSuspenseAvoidThisFallback = true;
|
||||
export const enableSuspenseAvoidThisFallbackFizz = false;
|
||||
export const enableCPUSuspense = true;
|
||||
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = true;
|
||||
export const enableClientRenderFallbackOnTextMismatch = true;
|
||||
export const enableComponentStackLocations = true;
|
||||
export const enableLegacyFBSupport = !__EXPERIMENTAL__;
|
||||
export const enableFilterEmptyStringAttributesDOM = false;
|
||||
|
||||
@@ -26,6 +26,7 @@ export const enableLazyContextPropagation = __VARIANT__;
|
||||
export const enableSyncDefaultUpdates = __VARIANT__;
|
||||
export const consoleManagedByDevToolsDuringStrictMode = __VARIANT__;
|
||||
export const enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay = __VARIANT__;
|
||||
export const enableClientRenderFallbackOnTextMismatch = __VARIANT__;
|
||||
export const enableTransitionTracing = __VARIANT__;
|
||||
export const enableSymbolFallbackForWWW = __VARIANT__;
|
||||
// Enable this flag to help with concurrent mode debugging.
|
||||
|
||||
@@ -32,6 +32,7 @@ export const {
|
||||
enableLazyContextPropagation,
|
||||
enableSyncDefaultUpdates,
|
||||
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay,
|
||||
enableClientRenderFallbackOnTextMismatch,
|
||||
} = dynamicFeatureFlags;
|
||||
|
||||
// On WWW, __EXPERIMENTAL__ is used for a new modern build.
|
||||
|
||||
Reference in New Issue
Block a user