Optimistic Updates with TRPC (react-query)?
I am not sure how I would do optimistic updates with trpc? Is this "built-in" or do I have to use react-query's useQuery hook?
So far, I am trying it like so, but it's not working:
Does this look like it should make sense? It's updating the value, but not optimistically.
3 Replies
I'm not sure what i'm doing wrong here, could somebody have a quick look? I feel maybe I need to wire up the useQueryClient in t3 stack first?
you should use trpc's useContext instead https://trpc.io/docs/useContext
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...
import api from t3 utils