Skip to main content

useIsomorphicLayoutEffect

Does exactly same as useLayoutEffect.

BUT will use useEffect in server side to prevent warning from Next.js or any SSR-framework.

const isBrowser = typeof window !== 'undefined';
const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;

API​

https://react.dev/reference/react/useLayoutEffect