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

useIsFetching.md

24 lines765 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```js
9import { useIsFetching } from 'react-query'
10// How many queries are fetching?
11const isFetching = useIsFetching()
12// How many queries matching the posts prefix are fetching?
13const isFetchingPosts = useIsFetching(['posts'])
14```
15​
16**Options**
17​
18- `queryKey?: QueryKey`: [Query Keys](../guides/query-keys)
19- `filters?: QueryFilters`: [Query Filters](../guides/filters#query-filters)
20​
21**Returns**
22​
23- `isFetching: number`
24 - Will be the `number` of the queries that your application is currently loading or fetching in the background.