-
|
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 yourfetchTrendinghas a return type annotation, then the types foruseQueryshould be inferred without having to provide generics:datareturned byuseTodoswill be correctly inferred toArray<Todo> | undefinedin this example