Move away from pathAndArgs
in @trpc/react
#267
Replies: 4 comments
-
The main reason is that the input arg is optional |
Beta Was this translation helpful? Give feedback.
-
I had it before that could do both useQuery |
Beta Was this translation helpful? Give feedback.
-
The second argument should be conditional on whether Input is undefined. Pseudocode: useQuery(path, args: Input extends undefined ? Opts : Input, opts?: Input extends undefined ? never : Opts); I can submit a PR for this. So you can see how it looks. |
Beta Was this translation helpful? Give feedback.
-
The thing is, the input can also be optional, and that doesn't work nicely in your suggestion as you'd be forced to pass like undefined/null in case you want to supply options. Id actually rather see if we can maybe mix in input in the query options and do like useQuery(path, { input, ...otherOpts }) |
Beta Was this translation helpful? Give feedback.
-
Really not a fan of the
pathAndArgs
syntax. Is there a reason for it? Instead oftrpc.useQuery(path, input, opts)
? Is this a relic of when you were supporting multiple inputs?Beta Was this translation helpful? Give feedback.
All reactions