Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9cf2ee3

Browse files
committedJul 22, 2024·
Stop handling hydration errors from unsupported React versions
1 parent 0dfcdea commit 9cf2ee3

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed
 

‎packages/next/src/client/components/react-dev-overlay/internal/container/RuntimeError/component-stack-pseudo-html.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function PseudoHtmlDiff({
6666
firstContent: string
6767
secondContent: string
6868
reactOutputComponentDiff: string | undefined
69-
hydrationMismatchType: 'tag' | 'text' | 'text-in-tag'
69+
hydrationMismatchType: 'tag' | 'text'
7070
} & React.HTMLAttributes<HTMLPreElement>) {
7171
const isHtmlTagsWarning = hydrationMismatchType === 'tag'
7272
const isReactHydrationDiff = !!reactOutputComponentDiff

‎packages/next/src/client/components/react-dev-overlay/internal/helpers/hydration-error-info.ts

+2-20
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,17 @@ const htmlTagsWarnings = new Set([
2121
'Warning: In HTML, %s cannot be a descendant of <%s>.\nThis will cause a hydration error.%s',
2222
'Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will cause a hydration error.',
2323
"Warning: In HTML, whitespace text nodes cannot be a child of <%s>. Make sure you don't have any extra whitespace between tags on each line of your source code.\nThis will cause a hydration error.",
24-
'Warning: Expected server HTML to contain a matching <%s> in <%s>.%s',
25-
'Warning: Did not expect server HTML to contain a <%s> in <%s>.%s',
2624
])
27-
const textAndTagsMismatchWarnings = new Set([
28-
'Warning: Expected server HTML to contain a matching text node for "%s" in <%s>.%s',
29-
'Warning: Did not expect server HTML to contain the text node "%s" in <%s>.%s',
30-
])
31-
const textMismatchWarning =
32-
'Warning: Text content did not match. Server: "%s" Client: "%s"%s'
3325

34-
export const getHydrationWarningType = (
35-
msg: NullableText
36-
): 'tag' | 'text' | 'text-in-tag' => {
26+
export const getHydrationWarningType = (msg: NullableText): 'tag' | 'text' => {
3727
if (isHtmlTagsWarning(msg)) return 'tag'
38-
if (isTextInTagsMismatchWarning(msg)) return 'text-in-tag'
3928
return 'text'
4029
}
4130

4231
const isHtmlTagsWarning = (msg: NullableText) =>
4332
Boolean(msg && htmlTagsWarnings.has(msg))
4433

45-
const isTextMismatchWarning = (msg: NullableText) => textMismatchWarning === msg
46-
const isTextInTagsMismatchWarning = (msg: NullableText) =>
47-
Boolean(msg && textAndTagsMismatchWarnings.has(msg))
48-
49-
const isKnownHydrationWarning = (msg: NullableText) =>
50-
isHtmlTagsWarning(msg) ||
51-
isTextInTagsMismatchWarning(msg) ||
52-
isTextMismatchWarning(msg)
34+
const isKnownHydrationWarning = (msg: NullableText) => isHtmlTagsWarning(msg)
5335

5436
export const getReactHydrationDiffSegments = (msg: NullableText) => {
5537
if (msg) {

0 commit comments

Comments
 (0)
Please sign in to comment.