SuspenseInfiniteQuery
Just as <SuspenseQuery/>
makes useSuspenseQuery easier to use in jsx, <SuspenseInfiniteQuery/>
serves to make useSuspenseInfiniteQuery easier to use in 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>
)