Skip to content

Differentiate refetching from actual loading #1574

Answered by TkDodo
adriandmitroca asked this question in General
Discussion options

You must be logged in to vote

you can't really differentiate it from background update that comes together with library.

I don't think that's true. when the query key changes:

  • a new entry will be created in the query cache
  • if this happens for the first time, there will be no data for that entry, unless you have keepPreviousData set to true or populated it with initialData.
  • because there is no data, the query will be in a "hard loading" state and isLoading will be true, which is not the case for background refetches.

Usually, it's enough to show a loading spinner if the query is in loading state. For background refetches, the query will stay in it's state (usually success) and the separate isFetching flag will be t…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@adriandmitroca
Comment options

@TkDodo
Comment options

@abhishekpoloju
Comment options

@TkDodo
Comment options

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