Skip to content
Discussion options

You must be logged in to vote

axios usually returns a Promise<any>, so make sure that your fetchTrending has a return type annotation, then the types for useQuery should be inferred without having to provide generics:

const fetchTodos = (): Promise<Array<Todo>> => (...)

const useTodos = useQuery('key', fetchTodos)

data returned by useTodos will be correctly inferred to Array<Todo> | undefined in this example

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kaisiant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants