-
Hey there! Apologies if this has been already discussed, but I am looking for the context behind the behaviour of the const { data } = useQuery('key', () => fetchData(), {
enabled: false,
}) will result in data equal to I am confused by this behaviour because when I decide to disable a query, I do it for a good reason. It's not only that I might not have enough information to make the Can you please explain to me a use case where it's desirable to use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Tbh, I've never seen a use-case where you'd enabled one and disable another observer of the same query. At least not on the same page, mounted at the same time. Maybe there is one, not really sure. By using custom hooks, you likely won't get into that situation though unless you want to :) |
Beta Was this translation helpful? Give feedback.
enabled
is an option that works on theobserver
level - so it can be different for eachuseQuery
instance. It just says that when used in this component, it will not trigger any data fetching. Of course, if data gets into the cache by any other means, e.g. because you fetch it manually, or because you callsetQueryData
for example, you will still get data even if the observer is disabled, because data in the cache will always be delivered to consumers.Tbh, I've never seen a use-case where you'd enabled one and disable another observer of the same query. At least not on the same page, mounted at the same time. Maybe there is one, not really sure. By using custom hooks, you likely won't ge…