Replies: 4 comments
-
@shrynx You can use an array with a string and any number of serializable objects. |
Beta Was this translation helpful? Give feedback.
-
yup i totally can and should but as i mentioned, this more for adding warning when they keys in array is not string as they silently fail during |
Beta Was this translation helpful? Give feedback.
-
Isn't this what Typescript is for? |
Beta Was this translation helpful? Give feedback.
-
that seems fair, if Also useQuery automatically coerces |
Beta Was this translation helpful? Give feedback.
-
Hi !
Thanks for the library, was longing for a solution like this for a while.
I got bit by this, had a query key like
['user', userId, 'posts']
but whereuserId
was a number.When using
useQuery
it worked and the userId was shows as a string in devtools but when trying to refetch usingqueryCache.refetchQueries
it didn't work and silently failed.although this is clearly mentioned in the documentation, would also be nice if the library warns on non string query key variables. In my case i had forgotten userId is not string.
Another solution would be to have automatically convert to string using
JSON.stringify
(that's what i end up doing most cases)Also i think
queryCache.refetchQueries
when provided with query keys that don't exists should also warnHappy to discuss further and make a PR if needed
Beta Was this translation helpful? Give feedback.
All reactions