SuspenseInfiniteQuery
<SuspenseQuery/>
๊ฐ useSuspenseQuery๋ฅผ jsx์์ ์ฝ๊ฒ ์ฌ์ฉํ๊ฒ ํ๋ ์ญํ ๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก <SuspenseInfiniteQuery/>
๋ useSuspenseInfiniteQuery๋ฅผ jsx์์ ์ฌ์ฉํ๊ธฐ ์ฝ๊ฒ ํ๊ธฐ ์ํ ์ญํ ์ ํฉ๋๋ค.
import { SuspenseInfiniteQuery } from '@suspensive/react-query'
import { Suspense, ErrorBoundary } from '@suspensive/react'
import { PostListItem } from '~/components'
const InfinitePostsPage = ({ userId }) => (
<ErrorBoundary fallback={({ error }) => <>{error.message}</>}>
<Suspense fallback="loading...">
<SuspenseInfiniteQuery {...postsInfiniteQueryOptions(userId)}>
{({ data, fetchNextPage }) => (
<>
{data.pages.map((post) => (
<PostListItem {...post} />
))}
<button
type="button"
onClick={() => {
fetchNextPage()
}}
>
Load More
</button>
</>
)}
</SuspenseInfiniteQuery>
</Suspense>
</ErrorBoundary>
)