DevThoughts
DevThoughts2y ago

where is useQuery [key]?

Learning trpc, i use to tanstack with queryKey, can not find how that works with trpc, if i want to revalidate my query? const query = useQuery({ queryKey: ['todos'], queryFn: getTodos })
Solution:
useContext | tRPC
useContext is a hook that gives you access to helpers that let you manage the cached data of the queries you execute via @trpc/react-query. These helpers are actually thin wrappers around @tanstack/react-query's queryClient methods. If you want more in-depth information about options and usage patterns for useContext helpers than what we provide...
Jump to solution
4 Replies
Nick
Nick2y ago
Nick
Nick2y ago
We have a dedicated integration, which also has the ability to get query keys if you need (but we do it for you)
DevThoughts
DevThoughtsOP2y ago
Yes, i have been reading the docs. How do i invalidateQueries when i use useMutation? i don't know my queryKey name? Thank you.
Solution
Nick
Nick2y ago
useContext | tRPC
useContext is a hook that gives you access to helpers that let you manage the cached data of the queries you execute via @trpc/react-query. These helpers are actually thin wrappers around @tanstack/react-query's queryClient methods. If you want more in-depth information about options and usage patterns for useContext helpers than what we provide...