T
TanStack3y ago
fascinating-indigo

Make useQuery re-run when refs change

Hello, i'm a React developer trying to get the hang of using vue-query with Vue Is there any example out there showcasing how do i go about making useQuery fire again when one of my refs change? Do i have to call it once inside the setup function and then again within the onUpdated lifecycle hook? I am pretty confused, Thanks in advance
4 Replies
ratty-blush
ratty-blush3y ago
No, just pass a ref to queryKey without unwrapping. So do not do queryKey: [myref.value], do queryKey: [myref]. vue-query will handle the rest for you
fascinating-indigo
fascinating-indigoOP3y ago
Holy fk, you're a legend. Is this mentioned anywhere in the docs? What i actually did to make it work before, was to wire up the refs with computed and then feed them into my query
ratty-blush
ratty-blush3y ago
I beleive it was mentioned in the old docs, but got lost in the new one. I need to make the pass trough the docs to add it back.
fascinating-indigo
fascinating-indigoOP3y ago
Thanks for taking the time to respond. I appreciate it

Did you find this page helpful?