框架
版本

useIsMutating

useIsMutating 是一个可选的 hook,它返回您的应用程序正在获取的 mutations 的 数量 (这对于应用范围的加载指示器很有用)。

tsx
import { useIsMutating } from '@tanstack/react-query'
// How many mutations are fetching?
const isMutating = useIsMutating()
// How many mutations matching the posts prefix are fetching?
const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })
import { useIsMutating } from '@tanstack/react-query'
// How many mutations are fetching?
const isMutating = useIsMutating()
// How many mutations matching the posts prefix are fetching?
const isMutatingPosts = useIsMutating({ mutationKey: ['posts'] })

选项

  • filters?: MutationFilters: Mutation Filters
  • queryClient?: QueryClient
    • 使用此选项可以使用自定义 QueryClient。否则,将使用最近上下文中的 QueryClient。

Returns (返回)

  • isMutating: number
    • 将是您的应用程序当前正在获取的 mutations 的 数量