@@ -53,12 +53,27 @@ import { useStableQueryArgs } from './useSerializedStableValue'
53
53
import { useShallowStableValue } from './useShallowStableValue'
54
54
55
55
// Copy-pasted from React-Redux
56
+ const canUseDOM = ( ) =>
57
+ ! ! (
58
+ typeof window !== 'undefined' &&
59
+ typeof window . document !== 'undefined' &&
60
+ typeof window . document . createElement !== 'undefined'
61
+ )
62
+
63
+ const isDOM = /* @__PURE__ */ canUseDOM ( )
64
+
65
+ // Under React Native, we know that we always want to use useLayoutEffect
66
+
67
+ const isRunningInReactNative = ( ) =>
68
+ typeof navigator !== 'undefined' && navigator . product === 'ReactNative'
69
+
70
+ const isReactNative = /* @__PURE__ */ isRunningInReactNative ( )
71
+
72
+ const getUseIsomorphicLayoutEffect = ( ) =>
73
+ isDOM || isReactNative ? useLayoutEffect : useEffect
74
+
56
75
export const useIsomorphicLayoutEffect =
57
- typeof window !== 'undefined' &&
58
- ! ! window . document &&
59
- ! ! window . document . createElement
60
- ? useLayoutEffect
61
- : useEffect
76
+ /* @__PURE__ */ getUseIsomorphicLayoutEffect ( )
62
77
63
78
export interface QueryHooks <
64
79
Definition extends QueryDefinition < any , any , any , any , any > ,
@@ -690,7 +705,10 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
690
705
// isFetching = true any time a request is in flight
691
706
const isFetching = currentState . isLoading
692
707
// isLoading = true only when loading while no data is present yet (initial load with no data in the cache)
693
- const isLoading = ( ! lastResult || lastResult . isLoading || lastResult . isUninitialized ) && ! hasData && isFetching
708
+ const isLoading =
709
+ ( ! lastResult || lastResult . isLoading || lastResult . isUninitialized ) &&
710
+ ! hasData &&
711
+ isFetching
694
712
// isSuccess = true when data is present
695
713
const isSuccess = currentState . isSuccess || ( isFetching && hasData )
696
714
0 commit comments