TanStackT
TanStack3y ago
14 replies
clean-aquamarine

Difference between `queryClient.clear()` and `queryClient.resetQueries()`?

Hey! I'm trying to understand what queryClient.clear does, which is not very clear at all based on https://tanstack.com/query/v4/docs/react/reference/QueryClient.

The basic use case is:
* User signs out of a mobile app
* Reset all queries, so that data is refetched as an unauthenticated user

It sounds like the method I want to be calling in this case is resetQueries, but I just wanted to confirm — anyone able to help out? And espeically would love to understand what .clear() is actually doing, I tried playing around with in the a codesandbox but I can't tell 😂

Thanks!
TanStack Query (FKA React Query) is often described as the missing data-fetching library for web applications, but in more technical terms, it makes fetching, caching, synchronizing and updating server state in your web applications a breeze.

Motivation
Overview | TanStack Query Docs
Was this page helpful?