wleistraW
tRPC4y 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 }
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 }
that by the time the call was made
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 ?? '' }
. I would love to get the old behavior back.
Was this page helpful?