框架
版本

useIsFetching

useIsFetching 是一个可选的钩子,它返回你的应用程序正在后台加载或获取的查询的数量(对于应用程序范围的加载指示器很有用)。

tsx
import { useIsFetching } from '@tanstack/solid-query'
// How many queries are fetching?
const isFetching = useIsFetching()
// How many queries matching the posts prefix are fetching?
const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })
import { useIsFetching } from '@tanstack/solid-query'
// How many queries are fetching?
const isFetching = useIsFetching()
// How many queries matching the posts prefix are fetching?
const isFetchingPosts = useIsFetching({ queryKey: ['posts'] })

选项

  • filters?: QueryFilters: 查询过滤器
  • queryClient?: QueryClient
    • 使用此选项可以使用自定义 QueryClient。否则,将使用最近上下文中的 QueryClient。

Returns (返回)

  • isFetching: number
    • 将是您的应用程序当前正在后台加载或获取的查询的 数量