File size: 423 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import { useEffect, useLayoutEffect } from 'react'
import { isSSR } from '../helpers'
/**
* Use this to read layout from the DOM and synchronously
* re-render if the isSSR returns true. Updates scheduled
* inside `useIsomorphicLayoutEffect` will be flushed
* synchronously in the browser, before the browser has
* a chance to paint.
*/
export const useIsomorphicLayoutEffect = isSSR() ? useEffect : useLayoutEffect
|