Skip to content
Discussion options

You must be logged in to vote

I think we're mixing two things here:

  1. if you pass staleTime to fetchQuery, data will be returned if its not older than the passed staleTime. This is documented here:

If the query exists and the data is not invalidated or older than the given staleTime, then the data from the cache will be returned. Otherwise it will try to fetch the latest data.

  1. react-query will not remove stale data even in case of error. What you should get is:
{
  status: 'error',
  data: theStaleData,
  error: yourError
}

if that is not the case, please provide a codesandbox reproduction.

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@fedebertolini
Comment options

@fedebertolini
Comment options

@TkDodo
Comment options

@fedebertolini
Comment options

@TkDodo
Comment options

Answer selected by fedebertolini
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