usePrefetchInfiniteQuery
usePrefetchInfiniteQuery๋ ์๋ฌด๊ฒ๋ ๋ฐํํ์ง ์์ผ๋ฉฐ, useSuspenseInfiniteQuery๋ฅผ ์ฌ์ฉํ๋ ์ปดํฌ๋ํธ๋ฅผ ๋ํํ๋ suspense boundary๊ฐ ๋ ๋ ๋๊ธฐ์ ์ prefetch๋ฅผ ๋ฐ์์ํค๋ ๋ฐ์ ์ฌ์ฉํฉ๋๋ค.
import {
usePrefetchInfiniteQuery,
useSuspenseInfiniteQuery,
} from '@suspensive/react-query'
const PostsPage = ({ postId }) => {
usePrefetchInfiniteQuery({
queryKey: ['posts'],
queryFn: () => getPosts(),
}) // suspense ๊ฒฝ๊ณ ์ ์ prefetch๋ฅผ ๋ฐ์ ์ํค๋ ๋ฐ์ ์ฌ์ฉํฉ๋๋ค
return (
<Suspense fallback={<div>Loading...</div>}>
<Posts />
</Suspense>
)
}
export const Posts = () => {
const postsInifiniteQuery = useSuspenseInfiniteQuery({
queryKey: ['posts'],
queryFn: () => getPosts(),
})
return <>...</>
}