how to pass trpc typescript between parent and children ?

I have data types when using useQuery but I want to also include these types inside the component that I am using here is an example const { data , isLoading, refetch } = api.users.submission.useQuery(undefined, { refetchOnWindowFocus: false }); <Submissions refetch={refetch} data={data} /> export default function Submission({refetch,data}) {} I want when I use data into Submission component I can see the data types that comes from useQuery, how can I achieve that ?
4 Replies
Liltripple_reid
Liltripple_reid3mo ago
you can use the RouterOutputs of the path you're querying
om3r
om3r3mo ago
is there a tutorial for this or an example how can I do that ? oh I see so I have to use it like this inside a variable and then use it ? const fils = data as RouterOutputs fils.users.submisison can I use it inside the props instead or its only inside a variable ?
Circus
Circus3mo ago
I don't really know what you're saying here, but what Liltripple was referring to was RouterOutputs, which would something like this export type RouterOutputs = inferRouterOutputs<AppRouter>; and then define your type, which for you would be something like export type Submission = RouterOutputs["users"]["submission"] https://trpc.io/docs/client/vanilla/infer-types
Inferring Types | tRPC
It is often useful to access the types of your API within your clients. For this purpose, you are able to infer the types contained in your AppRouter.
om3r
om3r3mo ago
yes i got it working , its my first time knowning about output I think i have to check trpc course because there is still alot of information missing , thanks man 🙂
Want results from more Discord servers?
Add your server
More Posts
pnpm/turbo workspace issueI have the following workspace setup: ``` packages: - apps/* - packages/* - packages/api/* -How to manage state in a vanilla js app in a functional programming wayThis question has been bugging me this week I would love to have some suggestions on this topic.React To Next header cookies/TokenHi, for some context. The backend is in python frontend in react and the auth system works by going "Weird" characters are visible in VSCode Git Bash terminal output (like this: `←[90m` )Hello, fellow theoists! I'm watching a new video from [Theo](https://youtu.be/d5x0JCZbAJs?t=2343), aNext Auth Drizzle Adapter does not include extra columns (fields)`auth.ts` ```ts providers: [ GoogleProvider({ clientId: env.GOOGLE_CLIENT_ID, clienuseUploadthing hook is slowHi, I recently started using Uploadthing. My use case involves attaching images to messages in my chCaching getSignedUrl without DB?In my tRPC using app, I store image files on Cloudflare R2. The client browse these images by listiVercel and Cloudflare DDoS protectionHello! I have a question, If I host my site on vercel and put static files on the site like logo orSystemError [ERR_TTY_INIT_FAILED]: TTY initialization failed: uv_tty_init returned EINVAL (invalid aI cloned create t3 app locally, then I tried to run it locally by first running pnpm install then pnAnimating a background moving between grid elementsI made this simple switch but I wanna animate the background moving from left to right instead of ha