T
TanStackโ€ข2mo ago
genetic-orange

useQueries: I want to get values and state from a specific query in the array with queryKey

Hi all. I've been trying to get something running but I've been hitting a wall for some reason... I have useQueries ( with queryOptions ) and for all the queries I run I have a queryKey built like: ['firstPart', 'secondPart', 'string_var']. Then I'm trying to get the specific data from the queries - I've got a map in rendering and the item has the 'string_var' available and when I try to get the specific query based on that 'string_var' using .find() since the useQueries is an array. But the queryKey is not available when I try to read the query.queryKey ... Am I missing something? Or am I trying to access it incorrectly? Cheers for any info or a link to the docs ๐Ÿ™‚ I've missed something obvious in the docs before... ๐Ÿ˜„
1 Reply
genetic-orange
genetic-orangeOPโ€ข2mo ago
For anyone else wondering something similar: check this comment from TkDodo -> https://github.com/TanStack/query/discussions/6752#discussioncomment-12341434 Was exactly what the doctor ordered ๐Ÿ˜„
GitHub
Return the QueryKey from useQuery ยท TanStack query ยท Discussion...
Generally we defining one hook that creates the query, and then reusing it all over our codebase export const useSomeThing = (someArg,Arg2):QueryResult => { return useQuery(["getSomeThing&q...

Did you find this page helpful?