fix(hydration): swap client/server labels for hydration mismatch warnings

this was swapped in #9098 but lost when merging #5953
This commit is contained in:
Evan You 2023-12-12 20:05:37 +08:00
parent ef688ba92b
commit f41fd86d5f
1 changed files with 10 additions and 10 deletions

View File

@ -173,10 +173,10 @@ export function createHydrationFunctions(
warn( warn(
`Hydration text mismatch in`, `Hydration text mismatch in`,
node.parentNode, node.parentNode,
`\n - rendered on server: ${JSON.stringify(vnode.children)}` + `\n - rendered on server: ${JSON.stringify(
`\n - expected on client: ${JSON.stringify( (node as Text).data
(node as Text).data )}` +
)}` `\n - expected on client: ${JSON.stringify(vnode.children)}`
) )
;(node as Text).data = vnode.children as string ;(node as Text).data = vnode.children as string
} }
@ -431,8 +431,8 @@ export function createHydrationFunctions(
warn( warn(
`Hydration text content mismatch on`, `Hydration text content mismatch on`,
el, el,
`\n - rendered on server: ${vnode.children as string}` + `\n - rendered on server: ${el.textContent}` +
`\n - expected on client: ${el.textContent}` `\n - expected on client: ${vnode.children as string}`
) )
el.textContent = vnode.children as string el.textContent = vnode.children as string
} }
@ -613,15 +613,15 @@ export function createHydrationFunctions(
hasMismatch = true hasMismatch = true
;(__DEV__ || __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) && ;(__DEV__ || __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) &&
warn( warn(
`Hydration node mismatch:\n- Client vnode:`, `Hydration node mismatch:\n- rendered on server:`,
vnode.type,
`\n- Server rendered DOM:`,
node, node,
node.nodeType === DOMNodeTypes.TEXT node.nodeType === DOMNodeTypes.TEXT
? `(text)` ? `(text)`
: isComment(node) && node.data === '[' : isComment(node) && node.data === '['
? `(start of fragment)` ? `(start of fragment)`
: `` : ``,
`\n- expected on client:`,
vnode.type
) )
vnode.el = null vnode.el = null