T
TanStack14mo ago
vicious-gold

Infinite query with maxPages scrolling

In my react-native app I have a list of posts supplied by an InifiniteQuery. When maxPages isn't set, it works as it should. Scroll to the bottom of the list -> new posts are fetched -> list gets longer -> I can scroll more. But when maxPages is set, there's an issue. Scroll to the bottom of the list -> new page is fetched -> first page in the cache is pushed out by the new page, so the list doesn't get any longer -> I can't scroll more. So basically because the list won't get longer, the posts at the current scroll position change, which is bad UX. Am I doing something wrong or missing something regarding maxPages? A solution that came to my mind was to use the current pageParam and the itemsPerPage value to calculate how many posts are missing and add placeholders to the returned data in the "select" function. This solution solves the proposed issue, BUT when scrolling back up in the the list, I need to call fetchPreviousPage when I reach the placeholder posts, but there's no event handler that fires at that point.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?