1 | import { useEffect, useLayoutEffect } from 'react';
|
2 | var isReactNative = typeof global !== 'undefined' && // @ts-ignore
|
3 | global.navigator && // @ts-ignore
|
4 | global.navigator.product === 'ReactNative';
|
5 | var 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 |
|
15 | export default isDOM || isReactNative ? useLayoutEffect : useEffect; |
\ | No newline at end of file |