/
githubmirror
/
react-beautiful-dnd
Обзор
Документация
Войти
/
githubmirror
/
react-beautiful-dnd
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/view/use-isomorphic-layout-effect.js
18 строк
809 B
LinusCenterstrom
Update useIsomorphicLayoutEffect check (#1636)
28 ноя 2019, 01:28
28 ноя 2019, 01:28
72a24eb
Код
Авторство
О чём код?
// @flow // eslint-disable-next-line no-restricted-imports import { useLayoutEffect, useEffect } from 'react'; // https://github.com/reduxjs/react-redux/blob/v7-beta/src/components/connectAdvanced.js#L35 // React currently throws a warning when using useLayoutEffect on the server. // To get around it, we can conditionally useEffect on the server (no-op) and // useLayoutEffect in the browser. We need useLayoutEffect because we want // `connect` to perform sync updates to a ref to save the latest props after // a render is actually committed to the DOM. const useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? useLayoutEffect : useEffect; export default useIsomorphicLayoutEffect;