T
TanStack3y ago
ambitious-aqua

Use prefetchQuery with trpc

Hey! I am using trpc + React Query. I need to prefetch some queries, however, it is asking me for the query function, which I dont really have since trpc handles everything. What is the best approach? Thanks
2 Replies
generous-apricot
generous-apricot3y ago
should work if you use the trpc useContext hook and call prefetch?
generous-apricot
generous-apricot3y 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...

Did you find this page helpful?