Open History to see the last commit
1---
2id: useIsMutating
3title: useIsMutating
4---
5β
6```ts
7function useIsMutating(
8 host: ReactiveControllerHost,
9 filters?: Accessor<MutationFilters<unknown, Error, unknown, unknown>>,
10 queryClient?: QueryClient): IsMutatingAccessor;
11```
12β
13Defined in: [packages/lit-query/src/useIsMutating.ts:141](https://github.com/TanStack/query/blob/main/packages/lit-query/src/useIsMutating.ts#L141)
14β
15Creates a Lit reactive controller that tracks how many matching mutations are
16currently pending.
17β
18When `filters` is a function, it is re-read during host updates so the count
19can follow reactive host state. If `queryClient` is omitted, the controller
20resolves the client from the nearest connected `QueryClientProvider`.
21β
22## Parameters
23β
24### host
25β
26`ReactiveControllerHost`
27β
28The Lit reactive controller host that owns the cache
29subscription.
30β
31### filters?
32β
33[`Accessor`](../type-aliases/Accessor.md)\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>\> = `{}`
34β
35Mutation filters, or a getter that returns mutation filters.
36β
37<a id="filters-properties"></a>
38β
39#### `filters` properties
40β
41Built from [`MutationFilters`](../interfaces/MutationFilters.md#properties). See the type above for what it changes.
42β
43### queryClient?
44β
45[`QueryClient`](../classes/QueryClient.md)
46β
47Optional explicit query client. Provide this for
48controllers that should not resolve a client from Lit context.
49β
50## Returns
51β
52[`IsMutatingAccessor`](../type-aliases/IsMutatingAccessor.md)
53β
54An accessor for the current number of matching pending mutations.
55β
56## Example
57β
58```ts
59import { LitElement, html } from 'lit'
60import { useIsMutating } from '@tanstack/lit-query'
61β
62class MutationStatus extends LitElement {
63 private readonly savesPending = useIsMutating(this, {
64 mutationKey: ['save-project'],
65 })
66β
67 render() {
68 return html`<span>${this.savesPending()} saves pending</span>`
69 }
70}
71```