tRPCttRPC
Powered by
thomasplayschessT
tRPC•3y ago•
73 replies
thomasplayschess

Wrapping useQuery into a custom hook

I'm trying to wrap
useQuery
useQuery
into a custom hook (as I have some legacy code that I need to run before). Example:

trpc.myendpoint.useQuery({ foo: 'bar' });
// instead of the code above, I want to write this:
useCustomHook(trpc.myendpoint, { foo: 'bar' })
trpc.myendpoint.useQuery({ foo: 'bar' });
// instead of the code above, I want to write this:
useCustomHook(trpc.myendpoint, { foo: 'bar' })


I'm able to write the JavaScript code, but I have trouble getting the TypeScript types right. I have more information in the Stackoverflow question here: https://stackoverflow.com/q/77096846

Thanks for any help ❤️
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?
Next page

Similar Threads

Invalid hook call using useQuery
JeiJJei / ❓-help
2y ago
useQuery hook modify data on fetch.
MajMMaj / ❓-help
3y ago
Create a typescript type that refers to a useQuery hook dynamically
Gh∅stGGh∅st / ❓-help
2y ago