GoScrobble/web/node_modules/@restart/hooks/esm/useIsomorphicEffect.js

15 lines
543 B
JavaScript
Raw Normal View History

2022-04-25 02:47:15 +00:00
import { useEffect, useLayoutEffect } from 'react';
var isReactNative = typeof global !== 'undefined' && // @ts-ignore
global.navigator && // @ts-ignore
global.navigator.product === 'ReactNative';
var isDOM = typeof document !== 'undefined';
/**
* Is `useLayoutEffect` in a DOM or React Native environment, otherwise resolves to useEffect
* Only useful to avoid the console warning.
*
* PREFER `useEffect` UNLESS YOU KNOW WHAT YOU ARE DOING.
*
* @category effects
*/
export default isDOM || isReactNative ? useLayoutEffect : useEffect;