should I use ctx or api?

whats the difference between me using api.events.getEvent.cancel() vs ctx.events.getEvent.cancel()? why does one work and not the other? isn't api in ctx, so shouldn't I be able to just use api and not ctx? which one should I be using?
No description
10 Replies
jacob
jacob16mo ago
What does the error say where the squiggly lines are under api
'tonyyprints'
'tonyyprints'16mo ago
No description
'tonyyprints'
'tonyyprints'16mo ago
No description
'tonyyprints'
'tonyyprints'16mo ago
I don't get why it doesnt exist for api, but it does for context
jacob
jacob16mo ago
Ah I see with API, you make calls like api.someProcedure.someFn.useQuery({}) They do different things, the trpc client context is seperate
'tonyyprints'
'tonyyprints'16mo ago
what exactly is the .cancel() stuff? it's not reactquery is it?
jacob
jacob16mo ago
Sorry, not the most proficient with trpc, I've only played with it a bit. Not sure
'tonyyprints'
'tonyyprints'16mo ago
all good, thanks anyways
Unknown User
Unknown User16mo ago
Message Not Public
Sign In & Join Server To View
cje
cje16mo ago
useContext is basically React Query's useQueryClient, adapted to tRPC. See documentation about it here: 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...