Skip to content
Discussion options

You must be logged in to vote

If it's about showing a global loading spinner, then callbacks are not the right thing, as they are for side effects.

What you are looking for is a way to show a global loading spinner, and there are two options for queries:

  1. suspense, as you already mentioned. It's tailor made for that case.
  2. the useIsFetching hook. While primarily made for background loading indicators (since this will fire for all fetches, not just initial loading), it can be tweaked to only notify on initial loading by passing the predicate filter function and only include queries where data is undefined or the state is loading.

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by cloudcompute
Comment options

You must be logged in to vote
1 reply
@TkDodo
Comment options

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