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?
10 Replies
What does the error say where the squiggly lines are under
api
I don't get why it doesnt exist for api, but it does for context
Ah I see
with API, you make calls like
api.someProcedure.someFn.useQuery({})
They do different things, the trpc client context is seperatewhat exactly is the .cancel() stuff?
it's not reactquery is it?
Sorry, not the most proficient with trpc, I've only played with it a bit. Not sure
all good, thanks anyways
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
useContext
is basically React Query's useQueryClient
, adapted to tRPC. See documentation about it here: https://trpc.io/docs/useContextuseContext | 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...