本页还没有译文
本页 16 段还没译成简体中文,下面显示的是英文原文。matchMutation
还没翻译译自英文(tanstack.com)本页 16 段都还没译
function matchMutation(filters: MutationFilters, mutation: Mutation<any, any>): boolean;Defined in: packages/query-core/src/utils.ts:269
Checks whether a mutation matches the given MutationFilters.
Every filter that is specified must match; filters that are left unspecified are ignored.
If a mutationKey filter is provided but the mutation has no mutationKey of its own, it does not match.
Parameters
filters
The filters to check the mutation against.
filters properties
| Property | Type | Description |
|---|---|---|
exact? | boolean | Match mutation key exactly |
mutationKey? | readonly unknown[] | Include mutations matching this mutation key |
predicate? | (mutation: Mutation<TData, TError, TVariables, TOnMutateResult>) => boolean | Include mutations matching this predicate function |
status? | "error" | "pending" | "success" | "idle" | Filter by mutation status |
mutation
Mutation<any, any>
The mutation to check.
Returns
boolean
true if the mutation matches every specified filter.
Example
const mutationCache = queryClient.getMutationCache()
const matchingMutations = mutationCache
.getAll()
.filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation))AI 翻译查看英文原文