Description
React version: 19.1.0
Steps To Reproduce
Using dangerouslySetInnerHTML or suppressHydrationWarning during hydration may result in client-side replacement of SSR-rendered DOM with empty content, rather than preserving the server-rendered markup.
const {
canHydrate = false,
children,
} = props;
const root = useRef<HTMLElement | null>(null)
useEffect(() => {
if (
root.current &&
canHydrate
) {
hydrateRoot(root.current, children)
}
}, [canHydrate, children])
return (
<section
ref={root}
dangerouslySetInnerHTML={{ __html: '' }}
suppressHydrationWarning
/>
)
The current behavior
dangerouslySetInnerHTML and suppressHydrationWarning change the ssr html to empty, and then hydrate fail
The expected behavior
dangerouslySetInnerHTML and suppressHydrationWarning cancel the hydration and keep the ssr html, and then manual hydration success