Skip to content

useReactorInfiniteQuery

useReactorInfiniteQuery is a React hook for paginated data fetching using a Reactor instance.

import { useReactorInfiniteQuery } from "@ic-reactor/react"
import { useReactorInfiniteQuery } from "@ic-reactor/react"
import { backend } from "./reactor"
function Feed() {
const { data, fetchNextPage, hasNextPage } = useReactorInfiniteQuery({
reactor: backend, // 👈 Required
functionName: "getPosts",
args: [],
getNextPageParam: (lastPage, allPages) => lastPage.nextCursor,
})
return (
<div>
{data?.pages.map((page) => (
// Render posts
<div key={page.id}>{/*...*/}</div>
))}
<button onClick={() => fetchNextPage()} disabled={!hasNextPage}>
Load More
</button>
</div>
)
}
OptionTypeDescription
reactorReactor<A, T>The Reactor instance to use
functionNamestringThe canister method to call
getNextPageParamfunctionFunction to determine the next page param (cursor/index)

Same as useActorInfiniteQuery.