`getPreviousPageParam` final parameter - is it the "current" page or is it the previous page?
Hi,
Sorry for the repeated queries, I'm just having a hard time getting my mind around
useInfiniteQuery
.
So the documentation code here:
If your API doesn't return a cursor, you can use the pageParam as a cursor. Because getNextPageParam and getPreviousPageParam also get the pageParam of the current page, you can use it to calculate the next / previous page param.
seems to contradict itself with the code:
In my experience just now, after calling fetchNextPage
several times, it seems that the firstPageParam
of the getPreviousPageParam
never seems to update. This would imply that the code above is correct in stating that it is the "first" page's param... Not the current?
my question is as in the title; is the third parameter of getPreviousPageParam
the actual current page or is it going to always be the first page that was requested? If it's the latter, why? Where do I actually obtain the current page?
If it's not the latter, then it means my code has some bug in it somewhere which is just getPreviousPageParam
to contain the wrong parameter.
1 Reply
ambitious-aquaOP•9mo ago
This may be helpful - above is the console.log that prints out the third paramter to both getlastpageparam and getfirstpageparam. As you can see, getLastPageParam never seems to update.
here is the code: