#{(typeof window !== 'undefined') && ( .....)} causes Error: Hydration failed error, anyone know why?
2 messages · Page 1 of 1 (latest)
reason: those <div> are not rendered during pre-render on the server, but are rendered during hydration, causing mismatch.
how to fix: use a state to control hydration instead
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
or use next/dynamic with ssr: false