Difference between queryCache.clear() vs queryCache.refetchQueries() #1231
-
When should I be using Does If I have a user switch accounts, should I run both |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hm, I haven't used either. I mostly do Tanner answered the question regarding the difference between
I'm pretty sure that Alternatively, you could also put the |
Beta Was this translation helpful? Give feedback.
Hm, I haven't used either. I mostly do
invalidateQueries
.Tanner answered the question regarding the difference between
refetchQueries
andinvalidateQueries
like this:I'm pretty sure that
queryCache.clear()
just removes the value from the cache, which I think is what you want when a user switches accounts. Once the user visits a page again where the query is observed, it will fetch again because it has no data. If you are certain that the data will be needed immediately, you couldrefetch
it right away.Alternatively, you could also put the
accountId
into th…