Skip to content
Discussion options

You must be logged in to vote

if you change the queryKey, react-query will refetch stale queries. refetchInterval does not prevent that, because that is a per-query-key setting, and you are switching the key. keepPreviousData also does not prevent it, because it just tells react-query to keep showing the old data until you have the new data when switching keys instead of showing a loading spinner. Kind of what suspense for data fetching is going to provide naturally. But it does not prevent a request.

what would prevent a request here is setting an appropriate staleTime. this time tells react-query for how long a query is to be considered fresh, and while data is fresh, you will always get it from the cache, without b…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@cristi-shoreline
Comment options

@TkDodo
Comment options

@cristi-shoreline
Comment options

Answer selected by cristi-shoreline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants