Here's my scenario, I have an infinite scroll list in React Native that I implemented with RTK Query using merge
and forceRefetch
, each time the user scrolls down to the bottom of the list I increment the current page number which will trigger a new page fetch with a new offset
param passed to the query. The newly fetched items are simply pushed to the end of the already existing list.
My issue is when I try to invalidate such a cache from another "Screen".
Ideally, after the mutation succeeds I want to invalidate this entire cache setting back the current page number to zero which will fetch only the first page so that if the current state of my cache contained a merged list of X pages it should now contain only the first page of let's say 20 items.
Now when I try to implement that using invalidatesTags
it always uses the last offset
param passed to it, even if I reset the current page number back to zero.
So I'm asking if there's a way we can invalidate the cache with new params? In my case I would like to invalidate the cache with a current page number set to zero so that the offset
would point to the first page.
Any insight is much appreciated.