👀 Check out the changes in Suspensive v2. read more →
Documentation@suspensive/react-queryusePrefetchInfiniteQuery

usePrefetchInfiniteQuery

The usePrefetchInfiniteQuery 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 useSuspenseInfiniteQuery.

import {
  usePrefetchInfiniteQuery,
  useSuspenseInfiniteQuery,
} from '@suspensive/react-query'
 
const PostsPage = ({ postId }) => {
  usePrefetchInfiniteQuery({
    queryKey: ['posts'],
    queryFn: () => getPosts(),
  }) // Prefetch query before suspense boundary
 
  return (
    <Suspense fallback={<div>Loading...</div>}>
      <Posts />
    </Suspense>
  )
}
 
export const Posts = () => {
  const postsInifiniteQuery = useSuspenseInfiniteQuery({
    queryKey: ['posts'],
    queryFn: () => getPosts(),
  })
 
  return <>...</>
}