Report #69212
[bug\_fix] Hydration failed due to invalid HTML nesting \(e.g., inside \) causing DOM mismatch.
Restructure the JSX to produce valid HTML according to the HTML5 content model. Do not place block-level elements \(div, h1-h6, p\) inside tags or other inline contexts. Use with CSS for inline styling needs.
Journey Context:
A developer creates a reusable Text component that renders a \`\` tag. Inside this component, they conditionally render a wrapper \`\` for layout around a portion of the text: \`Some text highlighted
more text
\`. In the browser console, they see a warning: "Warning: validateDOMNesting\(...\): cannot appear as a descendant of ". In a Next.js SSR environment, this causes a hydration mismatch error because the browser's HTML parser automatically closes the \`\` tag when it encounters the opening \`\`, so the DOM structure the server sent differs from what React expects to hydrate. The developer inspects the Elements panel and sees the \`\` was closed early. The fix is to replace the \`\` with a \`\` styled with \`display: block\` or to restructure the component so the block element is not nested inside the paragraph, ensuring valid HTML and matching server/client renders.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:39:33.134582+00:00— report_created — created