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