MCPcopy Create free account
hub / github.com/TanStack/query / useIsFetching

Function useIsFetching

packages/preact-query/src/useIsFetching.ts:8–23  ·  view source on GitHub ↗
(
  filters?: QueryFilters,
  queryClient?: QueryClient,
)

Source from the content-addressed store, hash-verified

6import { useSyncExternalStore } from './utils'
7
8export function useIsFetching(
9 filters?: QueryFilters,
10 queryClient?: QueryClient,
11): number {
12 const client = useQueryClient(queryClient)
13 const queryCache = client.getQueryCache()
14
15 return useSyncExternalStore(
16 useCallback(
17 (onStoreChange) =>
18 queryCache.subscribe(notifyManager.batchCalls(onStoreChange)),
19 [queryCache],
20 ),
21 () => client.isFetching(filters),
22 )
23}

Callers 2

IsFetchingFunction · 0.50
PageFunction · 0.50

Calls 5

useQueryClientFunction · 0.90
useSyncExternalStoreFunction · 0.90
getQueryCacheMethod · 0.80
subscribeMethod · 0.45
isFetchingMethod · 0.45

Tested by 2

IsFetchingFunction · 0.40
PageFunction · 0.40