Open History to see the last commit
1---
2id: useIsMutating
3title: useIsMutating
4redirect_from:
5 - framework/react/reference/useIsMutating
6---
7β
8```ts
9function useIsMutating(filters?: MutationFilters<unknown, Error, unknown, unknown>, queryClient?: QueryClient): number;
10```
11β
12Defined in: [packages/react-query/src/useMutationState.ts:33](https://github.com/TanStack/query/blob/main/packages/react-query/src/useMutationState.ts#L33)
13β
14The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending`
15(useful for app-wide loading indicators).
16β
17## Parameters
18β
19### filters?
20β
21[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>
22β
23The [MutationFilters](../interfaces/MutationFilters.md) to narrow down the matched mutations.
24β
25<a id="filters-properties"></a>
26β
27#### `filters` properties
28β
29| Property | Type | Description |
30| ------ | ------ | ------ |
31| <a id="filters-property-exact"></a> `exact?` | `boolean` | Match mutation key exactly |
32| <a id="filters-property-mutationkey"></a> `mutationKey?` | readonly `unknown`[] | Include mutations matching this mutation key |
33| <a id="filters-property-predicate"></a> `predicate?` | (`mutation`: [`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>) => `boolean` | Include mutations matching this predicate function |
34| <a id="filters-property-status"></a> `status?` | `"error"` \| `"pending"` \| `"success"` \| `"idle"` | Filter by mutation status |
35β
36### queryClient?
37β
38[`QueryClient`](../classes/QueryClient.md)
39β
40Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
41be used.
42β
43## Returns
44β
45`number`
46β
47Will be the `number` of the mutations that your application currently has `pending`.
48β
49## Example
50β
51```tsx
52import { useIsMutating } from '@tanstack/react-query'
53β
54function PostsMutatingIndicator() {
55 // How many mutations matching the posts prefix are in progress?
56 const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })
57β
58 return isMutatingPosts ? <span>Saving posts...</span> : null
59}
60```