import { useEffect , useLayoutEffect } from 'react' ; import { hasRequestAnimationFrame , hasWindow } from './helper' ; export const IS_SERVER = ! hasWindow ( ) || 'Deno' in window ; export const rAF = ( f ) => hasRequestAnimationFrame ( ) ? window [ 'requestAnimationFrame' ] ( f ) : setTimeout ( f , 1 ) ; export const useIsomorphicLayoutEffect = IS_SERVER ? useEffect : useLayoutEffect ; const navigatorConnection = typeof navigator !== 'undefined' && ( navigator as Navigator & { connection ? : { effectiveType : string ; saveData : boolean ; } ; } ) . connection ; export const slowConnection = ! IS_SERVER && navigatorConnection && ( [ 'slow-2g' , '2g' ] . includes ( navigatorConnection . effectiveType ) || navigatorConnection . saveData ) ;