can I use useUtils hook in trpc 11 ?
this is my trpc query, trpc query dont provide data, isLoading or error
also i want to invalidate my queries for example invalidate fetching posts query when doing a mutation (IN THE NEW WAY)
3 Replies
You must use
useQuery
from tanstack/react-query
and pass your tRPC queryOptions
to it like so:
https://trpc.io/docs/client/tanstack-react-query/usage
useUtils doesn't exist with trpc/tanstack-react-query
.
Instead use native Tanstack Query APIs to do the invalidation.TanStack React Query | tRPC
TanStack React Query usage
how about invalidating ?
You can see the all the utilities
@trpc/tanstack-react-query
provides in the documentation FluX linked