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
Jacob2y ago
What does the error say where the squiggly lines are under api
'antonyyprints'
I don't get why it doesnt exist for api, but it does for context
Jacob
Jacob2y ago
Ah I see with API, you make calls like api.someProcedure.someFn.useQuery({}) They do different things, the trpc client context is seperate
'antonyyprints'
what exactly is the .cancel() stuff? it's not reactquery is it?
Jacob
Jacob2y ago
Sorry, not the most proficient with trpc, I've only played with it a bit. Not sure
'antonyyprints'
all good, thanks anyways
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
cje
cje2y 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...
Want results from more Discord servers?
Add your server