Skip to content
Discussion options

You must be logged in to vote

Is there a better way to handle this kind of pagination?

you could always paginate "manually" with useQuery and keepPreviousData. if your query data contains the "link" to the next page, it should be as simple as:

const [page, setPage] = React.useState('someWayToIdentifyTheFirstPage')
const queryInfo = useQuery(['data', page], () => fetchData(page), { keepPreviousData: true })

<button onClick={() => setPage(queryInfo.data.next_page_uri)} disabled={queryInfo.isPreviousData || !queryInfo.data.next_page_uri}>Next</button>

is this the appropriate way to handle populating a 3rd party component given how useInfiniteQuery is returning data?

you can always do a custom hook and return the da…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@quickstark
Comment options

@quickstark
Comment options

@TkDodo
Comment options

Answer selected by quickstark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants