T
TanStack4y ago
genetic-orange

Query key returning data from a different hashed query key

I have a query key that looks like this
Key #1
[
{
"scope": "user",
"entity": "list",
"params": {
"favoriteColor": "red"
}
}
]
Key #1
[
{
"scope": "user",
"entity": "list",
"params": {
"favoriteColor": "red"
}
}
]
Then another key that looks like this
Key #2
[
{
"scope": "user",
"entity": "list",
"params": {
"favoriteColor": "red"
"ages": "12,23,45"
}
}
]
Key #2
[
{
"scope": "user",
"entity": "list",
"params": {
"favoriteColor": "red"
"ages": "12,23,45"
}
}
]
When there is a cached entry for #2, that data shows up for #1. Its it also worth noting the #1 is disabled. I am reusing the same hook, but disabling it if there is no 'ages' property. Im expecting data to be undefined because the query is disabled
2 Replies
flat-fuchsia
flat-fuchsia4y ago
disabled doesn't make data go undefined, it just means that this observer won't fetch any data on its own. If there is data in the cache for this key, it will be received. however, data from a different key should never be available. show a codesandbox reproduction please
genetic-orange
genetic-orangeOP4y ago
Yea thats why im confused. Ill see if I can replicate

Did you find this page helpful?