Can we support using symbols as keys? #477
-
I was really hoping that moving away from redux meant I could stop having awful action type strings like I still need to pass a key in to queries to ensure they're unique so now I have const Basket = Symbol('basket')
const [ basket ] = useQuery(Basket, fetchBasket) I guess the biggest complication is the fact that you need to serialize the keys? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
You can implement your own Custom Query Key Serializer that does exactly this. It's definitely not the majority use-case, so like it says, there be dragons, but I know of others that have done this without any problems. |
Beta Was this translation helpful? Give feedback.
-
I am visiting this issue as we just had a query key overlap in our project... and as I see there is no support of it. I guess, the only option we got is our old friend: |
Beta Was this translation helpful? Give feedback.
-
Sorry that the link to the accepted answer is not working anymore, I think this was a v2 thing. Since v3, you can pass a
But since you need to produce a string to serialize a query key, Ithink this still stands:
|
Beta Was this translation helpful? Give feedback.
You can implement your own Custom Query Key Serializer that does exactly this. It's definitely not the majority use-case, so like it says, there be dragons, but I know of others that have done this without any problems.