T
TanStack3y ago
plain-purple

TS best practice with `enabled` prop

Hi guys, basically I have an custom useQuery hook with an underlying queryFn that requires certain arguments. Now TS yells at me, because the type checker doesn't know that the query won't get enabled/executed until isValid=true . How do you guys handle this situation? I'd love to hear your opinion on this approach.
No description
1 Reply
extended-salmon
extended-salmon3y ago
React Query and TypeScript
Combine two of the most powerful tools for React Apps to produce great user experience, developer experience and type safety.

Did you find this page helpful?