Prevent SSR warnings with useIsomorphicLayoutEffect
useIsomorphicLayoutEffect is a drop-in replacement for useEffect and useLayoutEffect that resolves to useLayoutEffect in the browser and useEffect on the server. This prevents the common React warning about useLayoutEffect doing nothing during server-side rendering (SSR) while maintaining synchronous DOM measurement behavior on the client. It is ideal for projects using Next.js or Remix.import { useIsomorphicLayoutEffect } from '@reactuses/core';
function Demo() {
const [value] = useState("useIsomorphicLayoutEffect");
useIsomorphicLayoutEffect(() => {
window.console.log(value);
}, [value]);
return <div>{value}</div>;
}