Skip to content

How exactly does keepPreviousData work? Confused with cacheTime. #6054

Answered by kalijonn
shongs27 asked this question in Q&A
Discussion options

You must be logged in to vote

Disclaimer: Not a maintainer. Just a fellow user.

keepPreviousData is not for cache busting or fetching data when stale. keepPreviousData comes into play when the user navigates from page 1 to page 2. It is not about coming back to page 1. While we are fetching data for page 2, it ensures we're not displaying a 'loading' state and are displaying page 1 data. This is typically to avoid loading spinners when navigating from page 1 to page 2. While this is happening, the state would be of "status": "success", "fetchStatus": "fetching" and "isPreviousData": true.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@shongs27
Comment options

Answer selected by shongs27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants