Formik: Update field values from outside and rerun validation

Created on 26 Feb 2018  路  2Comments  路  Source: formium/formik

Bug, Feature, or Question?

Question

Current Behavior

mapPropsToValues updates the form values only once if enableReinitialize is false. Is this correct behaviour? Should I always set it to true to make mapPropsToValues update form every time?

Also updating props via mapPropsToValues does not run the validation. Is this expected behaviour?
How can I run the validation manually?

  • Formik Version: 0.11.11
  • React Version: 16.2.0
  • OS: MacOS Sierra
  • Node Version: v9.3.0
  • Package Manager and Version: yarn 1.3.2

Most helpful comment

^^ correct,

there is a PR open for a new onReinitialize prop. Would solve lots of use cases

All 2 comments

Hi @kennyx46 ,

One option I see: in your component you'd need to store reference to <Formik>'s FormikProps that are passed to child FAAC when the FAAC is rendered.
Then on componentWillReceiveProps() or similar, call FormikProps.validateForm();

https://github.com/jaredpalmer/formik#validateform-values-any--void

Let us know if it worked ;-)
Cheers

^^ correct,

there is a PR open for a new onReinitialize prop. Would solve lots of use cases

Was this page helpful?
0 / 5 - 0 ratings

Related issues

giulioambrogi picture giulioambrogi  路  3Comments

jeffbski picture jeffbski  路  3Comments

Jucesr picture Jucesr  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments

sibelius picture sibelius  路  3Comments