admin管理员组文章数量:1432205
I am using React Query with TypeScript.
Mutation:
let mutation = useMutation((newUser) => {
return signup(newUser)
})
Submit function:
const onSignupSubmit = ({ name, email, password }: User) => {
mutation.mutate(
{
name,
email,
password,
}
)
}
Also this line giving me error:
mutation?.error?.response?.data?.field
I am using React Query with TypeScript.
Mutation:
let mutation = useMutation((newUser) => {
return signup(newUser)
})
Submit function:
const onSignupSubmit = ({ name, email, password }: User) => {
mutation.mutate(
{
name,
email,
password,
}
)
}
Also this line giving me error:
mutation?.error?.response?.data?.field
Share
Improve this question
edited Apr 2, 2022 at 18:30
jonrsharpe
122k30 gold badges268 silver badges476 bronze badges
asked Apr 2, 2022 at 18:23
Bishal GiriBishal Giri
412 silver badges2 bronze badges
1
- 1 Please give a minimal reproducible example. Take the tour, read How to Ask. – jonrsharpe Commented Apr 2, 2022 at 18:27
1 Answer
Reset to default 6you need to define the type of the mutation function passed to useMutation
:
let mutation = useMutation((newUser: User) => {
return signup(newUser)
})
a shorter way would be to omit the arrow function and just do:
let mutation = useMutation(signup)
本文标签:
版权声明:本文标题:javascript - Argument of type '{ name: string; email: string; password: string; }' is not assignable to paramete 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745504827a2661197.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论