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

useIsMutating.md

57 lines1.7 KB

1---
2id: useIsMutating
3title: useIsMutating
4redirect_from:
5 - framework/solid/reference/useIsMutating
6---
7​
8<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
9​
10```ts
11function useIsMutating(filters?: Accessor<Omit<MutationFilters<unknown, Error, unknown, unknown>, "status">>, queryClient?: Accessor<QueryClient>): Accessor<number>;
12```
13​
14Defined in: [packages/solid-query/src/useIsMutating.ts:26](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useIsMutating.ts#L26)
15​
16The `useIsMutating` primitive returns the `number` of mutations that your application currently has `pending`
17(useful for app-wide loading indicators).
18​
19## Parameters
20​
21### filters?
22​
23`Accessor`\<`Omit`\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>, `"status"`\>\>
24​
25An accessor returning the [MutationFilters](../interfaces/MutationFilters.md) to narrow down the matched mutations.
26​
27<a id="filters-properties"></a>
28​
29#### `filters` properties
30​
31Built from [`MutationFilters`](../interfaces/MutationFilters.md#properties). See the type above for what it changes.
32​
33### queryClient?
34​
35`Accessor`\<[`QueryClient`](../classes/QueryClient.md)\>
36​
37An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context
38will be used.
39​
40## Returns
41​
42`Accessor`\<`number`\>
43​
44An accessor for the `number` of the mutations that your application currently has `pending`.
45​
46## Example
47​
48```tsx
49import { useIsMutating } from '@tanstack/solid-query'
50​
51function PostsMutatingIndicator() {
52 // How many mutations matching the posts prefix are in progress?
53 const isMutatingPosts = useIsMutating(() => ({ mutationKey: ['posts'] }))
54​
55 return isMutatingPosts() > 0 ? <span>Saving posts...</span> : null
57```