Open History to see the last commit
1---
2id: useIsMutating
3title: useIsMutating
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8```ts
9function useIsMutating(filters?: Omit<MutationFilters<unknown, Error, unknown, unknown>, "status">, queryClient?: QueryClient): number;
10```
11β
12Defined in: [packages/preact-query/src/useMutationState.ts:33](https://github.com/TanStack/query/blob/main/packages/preact-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`Omit`\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>, `"status"`\>
22β
23The [MutationFilters](../interfaces/MutationFilters.md) to narrow down the matched mutations.
24β
25<a id="filters-properties"></a>
26β
27#### `filters` properties
28β
29Built from [`MutationFilters`](../interfaces/MutationFilters.md#properties). See the type above for what it changes.
30β
31### queryClient?
32β
33[`QueryClient`](../classes/QueryClient.md)
34β
35Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
36be used.
37β
38## Returns
39β
40`number`
41β
42Will be the `number` of the mutations that your application currently has `pending`.
43β
44## Example
45β
46```tsx
47import { useIsMutating } from '@tanstack/preact-query'
48β
49function PostsMutatingIndicator() {
50 // How many mutations matching the posts prefix are in progress?
51 const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })
52β
53 return isMutatingPosts ? <span>Saving posts...</span> : null
54}
55```