Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resetForm must be called twice in order to clear values from localstorage #16

Open
kaitlynbrown opened this issue Dec 13, 2018 · 1 comment

Comments

@kaitlynbrown
Copy link

Because the componentDidUpdate method uses prevProps instead of this.props, when resetForm is called, it saves the values that existed in the form before resetting. Because of this, I can reset a form, then when I navigate away from it and then back, all the values that were in the form prior to resetting it reappear.

componentDidUpdate(prevProps: PersistProps & { formik: FormikProps<any> }) {
if (!isEqual(prevProps.formik, this.context.formik)) {
this.saveForm(prevProps.formik);
}
}

My current workaround is to simply call resetForm() twice. The second time, redux-persist will correctly save the empty form

@xxczaki
Copy link

xxczaki commented Apr 19, 2019

ping @jaredpalmer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants