【发布时间】:2022-02-04 02:30:50
【问题描述】:
这是相关代码:
const handleSubmit = async (event, values, actions) => {
event.preventDefault();
axios.post(url, payload(values.name))
.then(res => {
// do stuff
}).catch(err => {
// do other stuff
})
}
return (
<Formik
initialValues={{ name: 'Passwort' }}
onSubmit={handleSubmit(e, values, actions)}
>
{(props) => (
..
真的不喜欢我为了防止默认而传入e的方式。
这是默认的 Formik 代码,可以正常工作。但是如何防止默认呢?
<Formik
onSubmit={(values, actions) => {
// prevent default?
axios.post(url, payload(values.name))
.then(res => {
// do stuff
}).catch(err => {
// do other stuff
})
}
}
>
【问题讨论】:
标签: axios next.js formik chakra-ui