0

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)} 
2
  • Have you looked at formik.org/docs/api/… ? Commented Apr 11, 2021 at 10:49
  • not able to understand it Commented Apr 11, 2021 at 10:51

1 Answer 1

1
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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.