Open joduplessis opened 1 month ago
https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a
import useLayoutEffect from './use-isomorphic-layout-effect'; function App() { useLayoutEffect(() => { console.log('hello there'); }, []); return 'Hello world'; };
// use-isomorphic-layout-effect.js import { useLayoutEffect, useEffect } from 'react'; const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect; export default useIsomorphicLayoutEffect;
This doesn't appear to be an immediate issue if you use use client in NextJS.
use client
https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a