Invalidate infinite query after deleting items #2391
Replies: 3 comments 8 replies
-
hmm that's a really interesting case. can you make a codesandbox reproduction? |
Beta Was this translation helpful? Give feedback.
-
my paginate api taking offset as 0, 1, 2,3,4... and size=number. and in response i am not getting any offset or total page size param. just getting data. so how to handle getnextpageparam. and also i wants to implement delete item from infinite list |
Beta Was this translation helpful? Give feedback.
-
'lastPage', [ { totalExpensesAmount: 15792, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using
useInfinteQuery
hook to fetch paginated data. one edge case causing a bug:let's say user scrolled down until they reached the last page,
when deleting multiple items and based on that, the last page now doesn't exist on backend. when calling
invalidateQueries
after the mutation, all pages are re-fetched again. even though the last page is not exist now.the page param is
null
as returned fromgetNextPageParam
how to prevent calling the query function if pageParam is null?
I could do it manually by updating the cache but it seems like an unnecessary complexity. is there an easy way to do this?
Beta Was this translation helpful? Give feedback.
All reactions