Skip to content

useMutation: mutationFn callback data is of type void #4912

Answered by TkDodo
kelvin-homann asked this question in Q&A
Discussion options

You must be logged in to vote
  • useMutation has 4 generics, and the 3rd types variables, which you haven't typed, so it falls back to void.
  • it's a lot better to just type mutationFn and let the rest be inferred:
useMutation({
    mutationFn: (formData: string) => createFetch.bind(defaultApi, formData)(),
})

string is just an example - fill in with the real type of formData

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@kelvin-homann
Comment options

@TkDodo
Comment options

@fernandoperigolo
Comment options

Answer selected by louis-young
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants