reusing useQuery
I have a general hook that uses useQuery to fetch some data. I had a new use case in which i want to access the data returned from this query in a different place in my code.
I want to avoid using queryClient.getQueryData as it will not trigger a refresh when the data changes. So i tried calling the query like this
useQuery([key])
However, it gives me an error saying "missing queryFn". is it the case that I need always to pass my queryFn?
2 Replies
passive-yellow•3y ago
Yes, just make a custom hook and call that in multiple places
rare-sapphireOP•3y ago
okay, got it
Thx a lot