Formik: Form data are reset when state changes?

Created on 27 Aug 2018  路  2Comments  路  Source: formium/formik

Hi guys. I'm new to React & Formik.
I'm implementing a form that has a formik form & an image uploader
Whenever an image is uploaded i set its src value to component's state, then there comes an issue that all data which have been input into formik are reset. I think the reason may be the component is re-rendered when state changes and formik also is reset to its initial state.
Could someone please advise if i'm doing something wrongly?

Most helpful comment

If you change Formik's initialValues it will reset the form. You can turn this off by flagging the prop enableReinitialize

All 2 comments

If you change Formik's initialValues it will reset the form. You can turn this off by flagging the prop enableReinitialize

enableReinitialize

If I disable this option, can I work with Redux normally? I have a form that is used for both editing and data creation / entry. However, whenever a onChange event occurs in a select, the inputs texts are cleared.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jaredpalmer picture jaredpalmer  路  3Comments

ancashoria picture ancashoria  路  3Comments

sibelius picture sibelius  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments

pmonty picture pmonty  路  3Comments