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

useIsFetching.md

26 lines921 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(['posts'])
14```
15​
16**Options**
17​
18- `queryKey?: QueryKey`: [Query Keys](../guides/query-keys)
19- `filters?: QueryFilters`: [Query Filters](../guides/filters#query-filters)
20- `context?: React.Context<QueryClient | undefined>`
21 - Use this to use a custom React Query context. Otherwise, `defaultContext` will be used.
22​
23**Returns**
24​
25- `isFetching: number`
26 - Will be the `number` of the queries that your application is currently loading or fetching in the background.