Replies: 2 comments 4 replies
-
@TkDodo thoughts? Is this a viable idea? |
Beta Was this translation helpful? Give feedback.
-
The misunderstanding here is that you cannot disable a query per se. You can only create a disabled observer. An observer always has to observe a query, so we need to add the query to the cache. You can have multiple observers per query, some can be enabled, and some disabled. We treat the query as disabled as soon as all observers are disabled. A disabled observer just means: This observer will not fetch data on its own, but it will still receive updates if data winds up in the cache by other means. For example, you can have a disabled observer and still call In case it isn't clear: An observer gets created when you call |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Maybe we need one more option for useQuery & useInifiniteQuery, this option can help us to get rid of the unnecessary queryKey. For example: With this option when
enabled
isfalse
, thequeryKey
should be cleared and not shown in ReactQuery Devtool.Suggested option:
keyEnabled
: (boolean) optional.Example usage:
See below image we can see the queryKey persists as disabled status even if I set
enabled
tofalse
andcacheTime
to0
Beta Was this translation helpful? Give feedback.
All reactions