@@ -10,11 +10,14 @@ import { React } from '../utils/react'
10
10
// subscription is created and an inconsistent state may be observed
11
11
12
12
// Matches logic in React's `shared/ExecutionEnvironment` file
13
- export const canUseDOM = ! ! (
14
- typeof window !== 'undefined' &&
15
- typeof window . document !== 'undefined' &&
16
- typeof window . document . createElement !== 'undefined'
17
- )
13
+ const canUseDOM = ( ) =>
14
+ ! ! (
15
+ typeof window !== 'undefined' &&
16
+ typeof window . document !== 'undefined' &&
17
+ typeof window . document . createElement !== 'undefined'
18
+ )
19
+
20
+ const isDOM = /* @__PURE__ */ canUseDOM ( )
18
21
19
22
// Under React Native, we know that we always want to use useLayoutEffect
20
23
@@ -23,11 +26,13 @@ export const canUseDOM = !!(
23
26
*
24
27
* @see {@link https://github.com/facebook/react-native/issues/1331 Reference }
25
28
*/
26
- export const isReactNative =
29
+ export const isRunningInReactNative = ( ) =>
27
30
typeof navigator !== 'undefined' && navigator . product === 'ReactNative'
28
31
32
+ const isReactNative = /* @__PURE__ */ isRunningInReactNative ( )
33
+
29
34
const getUseIsomorphicLayoutEffect = ( ) =>
30
- canUseDOM || isReactNative ? React . useLayoutEffect : React . useEffect
35
+ isDOM || isReactNative ? React . useLayoutEffect : React . useEffect
31
36
32
37
export const useIsomorphicLayoutEffect =
33
38
/* @__PURE__ */ getUseIsomorphicLayoutEffect ( )
0 commit comments