UNPKG

543 BJavaScriptView Raw
1import { useEffect, useLayoutEffect } from 'react';
2var isReactNative = typeof global !== 'undefined' && // @ts-ignore
3global.navigator && // @ts-ignore
4global.navigator.product === 'ReactNative';
5var isDOM = typeof document !== 'undefined';
6/**
7 * Is `useLayoutEffect` in a DOM or React Native environment, otherwise resolves to useEffect
8 * Only useful to avoid the console warning.
9 *
10 * PREFER `useEffect` UNLESS YOU KNOW WHAT YOU ARE DOING.
11 *
12 * @category effects
13 */
14
15export default isDOM || isReactNative ? useLayoutEffect : useEffect;
\No newline at end of file