I have a form where some field's values depend on other fields values. I have been using redux-form and have been able to calculate these values using an onChange handler on the top-level form object.
I don't see an equivalent using formik, is this right? I thought I could hijack the validation function to do this, but it's not passed the formik bag, only the values to validate.
Another usecase for a form-level onChange is automatic persistence without needing to hit a submit button e.g. something like:
<Formik
initialValues={JSON.parse(localStorage.getItem('formvalues'))}
onChange={(values) => {
localStorage.setItem('formvalues', JSON.stringify(values))
}}
>
{/* … */}
</Formik>
Another option could be a "submitOnChange` flag.
I have a form where some field's values depend on other fields values. I have been using redux-form and have been able to calculate these values using an
onChangehandler on the top-level form object.I don't see an equivalent using formik, is this right? I thought I could hijack the validation function to do this, but it's not passed the formik bag, only the values to validate.
Another usecase for a form-level
onChangeis automatic persistence without needing to hit a submit button e.g. something like:Another option could be a "submitOnChange` flag.