-
I am using axios to request the api and the react query infers the type but it is not exactly what I want. So I set up the custom hook like below: My custom hook
How I using it
It seems to work, but can anyone point me out how to set up in a better way coz I am using any in the first two types. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
axios usually returns a
|
Beta Was this translation helpful? Give feedback.
axios usually returns a
Promise<any>
, so make sure that yourfetchTrending
has a return type annotation, then the types foruseQuery
should be inferred without having to provide generics:data
returned byuseTodos
will be correctly inferred toArray<Todo> | undefined
in this example