TanStackT
TanStack2y ago
8 replies
awake-maroon

Pagination with infinite query...

Hey everyone... i'm thinking to use infinite query to retrieve data for a table with pagination... but probably is not the right choice because if i go back my pages result
grows up... what am I doing wrong?....
for example if i look this:
useInfiniteQuery({
  queryKey: ['projects'],
  queryFn: fetchProjects,
  initialPageParam: 0,
  getNextPageParam: (lastPage, pages) => lastPage.nextCursor,
  getPreviousPageParam: (firstPage, pages) => firstPage.prevCursor,
})

and i have 2 page... i will have this output...
step1: pages Array(1)
go forward: Array(2)
go back: Array(3) with the same result of step1
Was this page helpful?