Skip to content
Discussion options

You must be logged in to vote

Now I see that I get multiple API calls for the same endpoint, which seems to originate from the fact that each component calls useQuery and triggers an initial API call.

If they mount at the same time, the fetch should be deduplicated. If they mount one after the other, like component 2 only mounts after component 1 has finished fetching, you will get a background refetch because staleTime defaults to 0. You can increase staleTime to define how "fresh" your resource is.

Replies: 1 comment 1 reply

Comment options

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

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