In React 18, when both "dangerouslySetInnerHTML={{ __html: '' }}" and "suppressHydrationWarning" are used together, the component's hydration process is canceled, preserving the server-side rendered (SSR) HTML. This allows developers to manually control the timing of hydration.
However, in React 19, this behavior has changed. Hydration proceeds and replaces the HTML with an empty string, resulting in a hydration error dialog being displayed.
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
/>
)`