T
TanStack2y ago
other-emerald

Making getQueryData reactive in Vue

Hello everyone 😄 I've been able to update JSX with .getQueryData(["/query-key"]) in react, but I can't seem to achieve the same in Vue... Any ideas on how to make .getQueryData(["/query-key"]) reactive?
2 Replies
rare-sapphire
rare-sapphire2y ago
useQuery is designed to reactively update on query cache updates. Could you elaborate why do you need getQueryData?
other-emerald
other-emeraldOP2y ago
Hi MrMentor, thank you very much for the response! I wanted to use it because I was unaware that the data returned from useQuery would be synchronised with the cache automatically/ out-of-the-box. What is even cooler is that data for multiple queries (made for the same query key) is synchronised throughout the app as well 🥳 ❤️ What I ended up doing was sharing the currently logged in user data (returned from useQuery) throughout the app. I achieved that via Context (in react) and provide -> inject (in vue)

Did you find this page helpful?