框架
版本

useIsMutating

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

tsx
import { useIsMutating } from '@tanstack/solid-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/solid-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: 突变过滤器
  • queryClient?: QueryClient
    • 使用此选项可以使用自定义 QueryClient。否则,将使用最近上下文中的 QueryClient。

Returns (返回)

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