Hey, does anyone have an example of how to only submit touched values. I'm currently using the formik HOC but the handleSubmit function doesn't have access to the touched prop.
If you are using withFormik HOC, it's handleSubmit have second argument with formikBag and props passed to component, including touched:
const formikEnhancer = withFormik({
handleSubmit: (payload, bag: { props: { touched } }) => {
console.log(touched);
},
displayName: "MyForm",
});
But all fields (that mentioned in initialValues) will be marked as touched on submit. So it will not help.
@funkyskank thanks, can鈥檛 believe I missed that.
It鈥檚 certainly a workaround but I could set up the equivalent of a hidden field in web land and populate via the fields that get touched.
Agree, this would be interesting in regards of atomic (database) updates.
Hi, I need a granular field update as well and can't figure out how to do that. I'm using <Formik> component and there's no touched on the onSubmit's formikBag object.
Is there a specific reason why it's not present there? Just to be clear, documentation is quite honest about it but doesn't mention any particular reason:
Note: errors, touched, status and all event handlers are NOT included in the FormikBag.
Most helpful comment
Hi, I need a granular field update as well and can't figure out how to do that. I'm using
<Formik>component and there's notouchedon theonSubmit'sformikBagobject.Is there a specific reason why it's not present there? Just to be clear, documentation is quite honest about it but doesn't mention any particular reason: