Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

useIsFetching.md

25 lines864 Bytes

1---
2id: useIsFetching
3title: useIsFetching
4---
5​
6`useIsFetching` is an optional hook that returns the `number` of the queries that your application is loading or fetching in the background (useful for app-wide loading indicators).
7​
8```tsx
9import { useIsFetching } from '@tanstack/react-query'
10// How many queries are fetching?
11const isFetching = useIsFetching()
12// How many queries matching the posts prefix are fetching?
13const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })
14```
15​
16**Options**
17​
18- `filters?: QueryFilters`: [Query Filters](../../guides/filters#query-filters)
19- `queryClient?: QueryClient`,
20 - Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
21​
22**Returns**
23​
24- `isFetching: number`
25 - Will be the `number` of the queries that your application is currently loading or fetching in the background.