-
If set, any previous data will be kept when fetching new data because the query key changed. Official document description. I don't understand this very well
Which one is correct? I think number 1 is the description of the official document. but number 1, Isn't showing that data if cacheTime is left by default even if keepPreviousData is not set? Let me assume the situation for understanding. ["blog", 1] is key value, and staleTime, cacheTime is the default. Let's assume that 1 is the page number, and we fetch to page 2 and return to page 1. In this operate, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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. |
Beta Was this translation helpful? Give feedback.
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.