-
Just to clarify, I don't have any issue with Say, I have a records that have 3 pages with a limit of 3 records/page: let's say the user load the first page (by default), then scroll down and load the second page. So you would have all 6 records and it would have fetched these 2 requests:
Say, the user deleted C record. I invalidated the I was worried it would perform same requests which is
Am I right from my understanding, that Thank you in advance, I just don't want to "code guessing" and want to actually understand it is how it is intended to work. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
when refetching, Then, for the second page, we don't use the stored param |
Beta Was this translation helpful? Give feedback.
when refetching,
useInfiniteQuery
always callsgetNextPageParam
for every fetch that isn't the first page. So in your scenario, when a refetch happens, we first fetch page1 with the storedpageParam
, which is probably theinitialPageParam
, which seems to be empty string or null in your case, leading to a fetch for/records
. That will returnA,B,D
.Then, for the second page, we don't use the stored param
C
, but we callgetNextPageParam
for that page. In there, your logic will probably returnD
, because that's the current value of the first page. That's how we can make the second fetch withlastId=D
. We'll continue this for all pages, or untilundefined
is returned fromgetNextPageParam
.