T
TanStack•3y ago
wise-white

What are the differences between refetch and invalidateQueries?

Hi, It is understood that invalidateQueries invalidates queries and active queries are reacquired in the background. When is refetch used?
2 Replies
stormy-gold
stormy-gold•3y ago
Invalidating queries just marks them as stale, so they'll be rerun if there are active observers for the query. Refetch will always rerun the query, even if there are no components subscribed to the data.
wise-white
wise-whiteOP•3y ago
@ergusto Thanks! >Refetch will always rerun the query, even if there are no components subscribed to the data. Does that mean it will fetch even if the query is not in an active state?🤔

Did you find this page helpful?