useQuery: When a value at query key changes and that changed value results to the false in enabled option, the returned data becomes initialValue(undefined in this case). #6062
-
Code
Console Output:
Based on my understanding, the false value in the enabled option is used to disable this query from automatically running. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
yes.
that's true.
that's not what's happening. You have two Queries in the cache. You should be able to see that when using the devtools.
when you tell So, bottom line: if you change the key, you observe a different cache entry, which knows nothing about the other cache entry you were observing before that. |
Beta Was this translation helpful? Give feedback.
yes.
that's true.
that's not what's happening. You have two Queries in the cache. You should be able to see that when using the devtools.
["100"]
and the data{data: true}
[""]
and the valueundefined
when you tell
useQuery
: Please give me data for key[""]
, it will give you what is in the cache, which isundefined
. Usually, it would go and fetch the data for you, but not if its disabled.So, bottom line: if you change the key, you observe a differ…