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.
Sebastian Markbåge committed
Feb 29, 2024 at 20:27 UTC
bb4b147da9a892529995f55f15f19f46a00cf4f6
5 files changed
+4
-24
packages/react-dom-bindings/src/client/ReactDOMComponent.js
-7
@@ -2977,13 +2977,6 @@ export function warnForInsertedHydratedText(
2977
text: string,
2978
) {
2979
if (__DEV__) {
2980
- if (text === '') {
2981
- // We expect to insert empty text nodes since they're not represented in
2982
- // the HTML.
2983
- // TODO: Remove this special case if we can just avoid inserting empty
2984
- // text nodes.
2985
- return;
2986
- }
2980
if (didWarnInvalidHydration) {
2981
return;
2982
}
packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js
-4
@@ -1026,10 +1026,6 @@ export function bindInstance(
1026
1027
export const supportsHydration = true;
1028
1029
-export function isHydratableText(text: string): boolean {
1030
- return text !== '';
1031
-}
1032
-
1029
export function canHydrateInstance(
1030
instance: HydratableInstance,
1031
type: string,
packages/react-reconciler/src/ReactFiberConfigWithNoHydration.js
-1
@@ -21,7 +21,6 @@ function shim(...args: any): empty {
21
// Hydration (when unsupported)
22
export type SuspenseInstance = mixed;
23
export const supportsHydration = false;
24
-export const isHydratableText = shim;
24
export const isSuspenseInstancePending = shim;
25
export const isSuspenseInstanceFallback = shim;
26
export const getSuspenseInstanceFallbackErrorDetails = shim;
packages/react-reconciler/src/ReactFiberHydrationContext.js
+4
-11
@@ -74,7 +74,6 @@ import {
74
canHydrateSuspenseInstance,
75
canHydrateFormStateMarker,
76
isFormStateMarkerMatching,
77
- isHydratableText,
77
validateHydratableInstance,
78
validateHydratableTextInstance,
79
} from './ReactFiberConfig';
@@ -517,21 +516,15 @@ function tryToClaimNextHydratableTextInstance(fiber: Fiber): void {
516
return;
517
}
518
const text = fiber.pendingProps;
520
- const isHydratable = isHydratableText(text);
519
520
let shouldKeepWarning = true;
523
- if (isHydratable) {
524
- // Validate that this is ok to render here before any mismatches.
525
- const currentHostContext = getHostContext();
526
- shouldKeepWarning = validateHydratableTextInstance(
527
- text,
528
- currentHostContext,
529
- );
530
- }
521
+ // Validate that this is ok to render here before any mismatches.
522
+ const currentHostContext = getHostContext();
523
+ shouldKeepWarning = validateHydratableTextInstance(text, currentHostContext);
524
525
const initialInstance = nextHydratableInstance;
526
const nextInstance = nextHydratableInstance;
534
- if (!nextInstance || !isHydratable) {
527
+ if (!nextInstance) {
528
// We exclude non hydrabable text because we know there are no matching hydratables.
529
// We either throw or insert depending on the render mode.
530
if (shouldClientRenderOnMismatch(fiber)) {
packages/react-reconciler/src/forks/ReactFiberConfig.custom.js
-1
@@ -134,7 +134,6 @@ export const cloneHiddenTextInstance = $$$config.cloneHiddenTextInstance;
134
// Hydration
135
// (optional)
136
// -------------------
137
-export const isHydratableText = $$$config.isHydratableText;
137
export const isSuspenseInstancePending = $$$config.isSuspenseInstancePending;
138
export const isSuspenseInstanceFallback = $$$config.isSuspenseInstanceFallback;
139
export const getSuspenseInstanceFallbackErrorDetails =