Replies: 1 comment 1 reply
-
I think you meant export function hashKey(queryKey: QueryKey | MutationKey): string {
return JSON.stringify(queryKey, (_, val) => {
const thingToHash =
val instanceof Map || val instanceof Set
? Object.fromEntries([...val.entries()])
: val;
return isPlainObject(thingToHash)
? Object.keys(thingToHash)
.sort()
.reduce((result, key) => {
result[key] = thingToHash[key];
return result;
}, {} as any)
: thingToHash;
});
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
query/packages/query-core/src/utils.ts
Lines 180 to 191 in 0a181d5
Using
Map/Set
as a query key has some slightly non-intuitive behavior because of the fact thatObject.values(new Map([ ['foo', 'bar'] ]))
=>[]
.We could probably fix it with something like this. But I wanted to see what people think about this before I put a PR up.
Beta Was this translation helpful? Give feedback.
All reactions