Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 1.03 KB

File metadata and controls

25 lines (17 loc) · 1.03 KB
id usePrefetchQuery
title usePrefetchQuery
usePrefetchQuery(options)

Options

You can pass everything to usePrefetchQuery that you can pass to queryClient.prefetchQuery. Remember that some of them are required as below:

For general imperative fetching outside render, prefer queryClient.query. This hook specifically mirrors the legacy prefetch behavior during render.

  • queryKey: QueryKey

    • Required
    • The query key to prefetch during render
  • queryFn: (context: QueryFunctionContext) => Promise<TData>

    • Required, but only if no default query function has been defined See Default Query Function for more information.

Returns

The usePrefetchQuery does not return anything, it should be used just to fire a prefetch during render, before a suspense boundary that wraps a component that uses useSuspenseQuery.