T
TanStack3y ago
rival-black

Pagination - show loader

Im using useQuery for paginated data - i have keepPreviousData:true - to make my pagination not disappear while changing pages. I would like to show loader state only when there is no cached queryKey. For example: 1.Initial list loading - im using isLoading to show only spinner 2.First page loaded, Im clicking on page no 2. 3.Data for page no 2 is loading now. IsLoading flag will be false, because of keepPreviousData: true. My pagination is not disappearing, but I want to make my list of data disappear and show there only loader. 4.Im clicking back to page 1 - data is not stale yet, so there should be no any loader - just instant switch between pages. Im wondering what loader state should i use?
3 Replies
flat-fuchsia
flat-fuchsia3y ago
isPreviousData
rival-black
rival-blackOP3y ago
keepPreviousData:true here does really do nothing, but its simplified example. Hope this is the best solution?

Did you find this page helpful?