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

useIsMutating.md

25 lines822 Bytes

1---
2id: useIsMutating
3title: useIsMutating
4---
5​
6`useIsMutating` is an optional hook that returns the `number` of mutations that your application is fetching (useful for app-wide loading indicators).
7​
8```tsx
9import { useIsMutating } from '@tanstack/react-query'
10// How many mutations are fetching?
11const isMutating = useIsMutating()
12// How many mutations matching the posts prefix are fetching?
13const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })
14```
15​
16**Options**
17​
18- `filters?: MutationFilters`: [Mutation Filters](../guides/filters.md#mutation-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- `isMutating: number`
25 - Will be the `number` of the mutations that your application is currently fetching.