Skip to content

keepPreviousData deprecated - what now? #6460

Answered by TkDodo
ffxsam asked this question in Q&A

You must be logged in to vote

and when I navigate through our app, I always see the previously cached data shown.

That's the default behaviour, yes, but it has nothing to do with placeholderData. When you navigate through your app, you likely change components, and those have different useQuery calls, observering different parts of the cache. When cached data is available, you'll always get it plus potentially a background refetch (stale-while-revalidate).

What keepPreviousData (and the placholderData function replacement in v5) does is give you data from the previous query when you change from one query to the next in the same observer (component). That usually happens when the queryKey changes. It's meant to give …

Replies: 2 comments 5 replies

You must be logged in to vote
3 replies
@ffxsam

@TkDodo

Answer selected by ffxsam
@ffxsam

You must be logged in to vote
2 replies
@LeulAria

@hnrchrdl

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