Conditional trpc hook query
When calling a trpc hook, is there a way to only make it call, if the input is validated client side?
Im using zod on server side. But sometimes it takes some time on client side before the data is valid.
Example:
In this case im using debounced values.
This results in a bunch of bad type zod errors before the values are correct.
And conditionally rendering hooks gives errors.
So how to only conditionally fetch trpc?
3 Replies
You have a enabled property to "hold" the query until it's valid
It's the second possible object of the query
Something like this perhaps? It would only fire the query if parsedInput is a number that is greater than 5 for example
Thank you! I will give it a try