Clean up empty string special cases (#28475)

This was fixed in https://github.com/facebook/react/pull/22807 so we
don't need these special cases anymore.
This commit is contained in:
Sebastian Markbåge
2024-02-29 20:27:26 -05:00
committed by GitHub
parent b8da12e8f8
commit bb4b147da9
5 changed files with 4 additions and 24 deletions
@@ -2977,13 +2977,6 @@ export function warnForInsertedHydratedText(
text: string,
) {
if (__DEV__) {
if (text === '') {
// We expect to insert empty text nodes since they're not represented in
// the HTML.
// TODO: Remove this special case if we can just avoid inserting empty
// text nodes.
return;
}
if (didWarnInvalidHydration) {
return;
}
@@ -1026,10 +1026,6 @@ export function bindInstance(
export const supportsHydration = true;
export function isHydratableText(text: string): boolean {
return text !== '';
}
export function canHydrateInstance(
instance: HydratableInstance,
type: string,
@@ -21,7 +21,6 @@ function shim(...args: any): empty {
// Hydration (when unsupported)
export type SuspenseInstance = mixed;
export const supportsHydration = false;
export const isHydratableText = shim;
export const isSuspenseInstancePending = shim;
export const isSuspenseInstanceFallback = shim;
export const getSuspenseInstanceFallbackErrorDetails = shim;
+4 -11
View File
@@ -74,7 +74,6 @@ import {
canHydrateSuspenseInstance,
canHydrateFormStateMarker,
isFormStateMarkerMatching,
isHydratableText,
validateHydratableInstance,
validateHydratableTextInstance,
} from './ReactFiberConfig';
@@ -517,21 +516,15 @@ function tryToClaimNextHydratableTextInstance(fiber: Fiber): void {
return;
}
const text = fiber.pendingProps;
const isHydratable = isHydratableText(text);
let shouldKeepWarning = true;
if (isHydratable) {
// Validate that this is ok to render here before any mismatches.
const currentHostContext = getHostContext();
shouldKeepWarning = validateHydratableTextInstance(
text,
currentHostContext,
);
}
// Validate that this is ok to render here before any mismatches.
const currentHostContext = getHostContext();
shouldKeepWarning = validateHydratableTextInstance(text, currentHostContext);
const initialInstance = nextHydratableInstance;
const nextInstance = nextHydratableInstance;
if (!nextInstance || !isHydratable) {
if (!nextInstance) {
// We exclude non hydrabable text because we know there are no matching hydratables.
// We either throw or insert depending on the render mode.
if (shouldClientRenderOnMismatch(fiber)) {
@@ -134,7 +134,6 @@ export const cloneHiddenTextInstance = $$$config.cloneHiddenTextInstance;
// Hydration
// (optional)
// -------------------
export const isHydratableText = $$$config.isHydratableText;
export const isSuspenseInstancePending = $$$config.isSuspenseInstancePending;
export const isSuspenseInstanceFallback = $$$config.isSuspenseInstanceFallback;
export const getSuspenseInstanceFallbackErrorDetails =