tRPCttRPC
Powered by
wleistraW
tRPC•4y ago•
2 replies
wleistra

Type issue react query with enabled.

We migrate to trpc and using @tanstack/react-query directly to the trpc syntax of trpc.procedureName.useQuery(). Previously TypeScript understood that if an input like
{ id: string }
{ id: string }
to the useQuery was possibly null or undefined (because it comes from useParams() react-router hook for example) and the option on the useQuery was set to
{ enabled: !!id }
{ enabled: !!id }
that by the time the call was made
id
id
would indeed be a string. Now that we migrated to using trpc TS errors out and expects us to do silly things like
{ id: string ?? '' }
{ id: string ?? '' }
. I would love to get the old behavior back.
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Type safety with enabled option
alexAalex / ❓-help
4y ago
CreateCaller with React-query
lunacraftsLlunacrafts / ❓-help
2y ago
Type mismatch with queryClient prop of @trpc/react-query
MadyanMMadyan / ❓-help
15mo ago
Make meta in react-query type-safe.
infodushaIinfodusha / ❓-help
2y ago