T
tRPC

❓-help

How to use querykeys from react-query

DDR34M2/9/2023
I am trying to implement a search query to an api that i am fetching via a procedure, i also read on getQueryKey but im not sure i understand how i can implement it now
Nnlucas2/9/2023
You don’t need to do anything special to calculate a query key if you’re just controlling the input to a query You just do const myQuery = trpc.my.router.procedure.useQuery({ filterParam: filterValue })
Nnlucas2/9/2023
useQuery() | tRPC
The hooks provided by @trpc/react-query are a thin wrapper around @tanstack/react-query. For in-depth information about options and usage patterns, refer to their docs on queries.
DDR34M2/9/2023
thanks...will give feedback
DDR34M2/9/2023
so i used a useDebounce hook to delay making a call to the api but turns out while im typing its making calls to the api that are empty then after my set delay and after ive written what to search it calls again and brings back results... i want it to only request to the api after the delay
DDR34M2/9/2023
Nnlucas2/9/2023
Those console logs aren't showing network calls, they're showing renders What does the network debugger say? If you want to only enable the query after a certain condition is met then you can use the enabled option in useQuery Otherwise it will fetch with the initial value and then once the debounce turns over

Looking for more? Join the community!

Recommended Posts
Distribute typesafe tRPC Client in an NPM libraryHi ! super fan of trpc over here. We are building a javascript sdk for our API that is essentiallyWebsocket is not defined errorI'm getting a "WebSocket is not defined error" on my next app connected to an express backend. Any i@trpc/server in a non-server environment Error in Azure CIIm trying to add vitest unit tests for my trpc procedures. I followed some examples and on the localHow are people handling authorization?I noticed that with V10, any mentions of `trpc-shield` are gone from the documentation. Also, it onlVitest context router callerHi, Im trying to setup vitest to test trpc. I would like to have a trpc approuter caller to be accesWebSocket connection hangs after significant amount of data passed through the connection.Hey! I've been really enjoying using tRPC on my latest project, but have gotten stuck getting websoCannot read properties of undefined (reading 'data') of res.error.data, when trpc errors outHello everyone, I am using `@trpc/react-query` alongside `trpc` for express, and I am experiencing aIs there an example of a real world non trivial app?Something that includes type inference, nested fields, calculated fields, nested React components thHow to organise output types?I'm having a hard time trying to figure out what the best way to organise output types and I was wonExtending middlewareshttps://trpc.io/docs/middlewares#extending-middlewares Is this available?Calling a trpc endpoint inside of a trpc endpointHey all. I'm wondering how I am able to call these endpoints from within themselves? For example,Frozen input paramIs it possible to define a parameter on input schema (zod) that will have a hardcoded/frozen value wtype mismatch between tRPC return (in sveltekit) and defined typei've got this piece of code: ```ts read: async () => { const res = await trpc($page).getCards.querpre fetch serveral prodecures dynamicallyHello!. I'm developing a React Native app which needs an offline mode for some assets that the user procedure input contextIs it possible to accesss context in trpc procedure input validation? I have an aray of values in tIs it normal to separate resolvers from routers?Wondering if it's common and/or whether it's a good idea to attempt to separate procedures from the i have an infinite loop within my hook but apps works as expected.when i console log inside this hook, it repeats non-stop every few seconds, but my app is working astrpc query running twiceHey guys. I have a trpc endpoint which makes a request to the discord api to fetch a list of the usetRPC Call To ServerOn the mobile version of my app, in NextJS, the build has to be static so I have to use my hosted weGet count of stages assigned to user with stage name?Need help in writing prisma query to get stages assigned to user with stage name? this is the scheme