reactjs: formik: onSubmit 回调函数:我可以使用哪些参数
reactjs: formik: onSubmit callback function: what parameters i can use
在 Formik 形式中我们看到
<Formik
onSubmit={someCallBack}
>
</Formik>
而且我看到 someCallBack
函数定义了各种参数,例如
function someCallBack(values,props){
}
function someCallBack({setSubmitting}){
}
那么 Formik 如何知道要将哪些参数传递给回调。
谁能解释一下语法。
我能理解
onSubmit = {(e) => someCallBack(e,value,props)}
onSubmit: (values: Values, formikBag: FormikBag) => void | Promise<any>
It is passed your forms values and the "FormikBag", which includes an object containing a subset of the injected props and methods (i.e. all the methods with names that start with set + resetForm) and any props that were passed to the wrapped component. Note: errors, touched, status and all event handlers are NOT included in the FormikBag.
https://formik.org/docs/api/formik#onsubmit-values-values-formikbag-formikbag--void--promiseany
在 Formik 形式中我们看到
<Formik
onSubmit={someCallBack}
>
</Formik>
而且我看到 someCallBack
函数定义了各种参数,例如
function someCallBack(values,props){
}
function someCallBack({setSubmitting}){
}
那么 Formik 如何知道要将哪些参数传递给回调。
谁能解释一下语法。
我能理解
onSubmit = {(e) => someCallBack(e,value,props)}
onSubmit: (values: Values, formikBag: FormikBag) => void | Promise<any>
It is passed your forms values and the "FormikBag", which includes an object containing a subset of the injected props and methods (i.e. all the methods with names that start with set + resetForm) and any props that were passed to the wrapped component. Note: errors, touched, status and all event handlers are NOT included in the FormikBag.
https://formik.org/docs/api/formik#onsubmit-values-values-formikbag-formikbag--void--promiseany