T
TanStack2y ago
fair-rose

While a query is disabled it still creates entries in the query cache

I noticed that even if a query is set to enabled: false it still creates entries in the query cache when the query key changes. Is that the desired behavior or am I doing something wrong?
6 Replies
fair-rose
fair-roseOP2y ago
I have create a Stackblitz here to showcase what I mean https://stackblitz.com/edit/vite-vue3-ts-tailwind-mdfjg2?file=src%2Fpages%2FHome.vue
Giannis Koutsaftakis
StackBlitz
Vue query - disabled query - StackBlitz
Next generation frontend tooling. It's fast!
fair-rose
fair-roseOP2y ago
You'll see that the cache gets populated with empty entries when you increment the counter even if the query is disabled
No description
correct-apricot
correct-apricot2y ago
yes, it's the desired behaviour.
rival-black
rival-black2y ago
Yes. This only disabled calling the queryFn
fair-rose
fair-roseOP2y ago
@M00LTi can you elaborate more?
rival-black
rival-black2y ago
By using useQuery you create the observer that watches cache store. Even if it's disabled you want to be updated when another component has the same query enabled, or you call queryClient.setQueryData.

Did you find this page helpful?