DR33M
DR33M17mo ago

How to use querykeys from react-query

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
6 Replies
Nick
Nick17mo ago
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 })
Nick
Nick17mo ago
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.
DR33M
DR33M17mo ago
thanks...will give feedback
DR33M
DR33M17mo ago
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
DR33M
DR33M17mo ago
Nick
Nick17mo ago
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
More 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 websoTrpc Vanilla client producing ts errorsCreating a vanilla trpc client to hopefully use in my Plasmo Extension and it gives me this error WCannot 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 won