Reputation: 11788
In Formik Form we see
<Formik
onSubmit={someCallBack}
>
</Formik>
And i have seen someCallBack
function defined with various parameterts like
function someCallBack(values,props){
}
function someCallBack({setSubmitting}){
}
So how Formik know what parameters to be passed to the callback.
Can someone explain the syntax.
I can understand
onSubmit = {(e) => someCallBack(e,value,props)}
Upvotes: 0
Views: 4391
Reputation: 2131
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
Upvotes: 1