jaredpalmer / formik-persist

💾 Persist and rehydrate a Formik form to localStorage
MIT License
376 stars 56 forks source link

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

Open kaitlynbrown opened 5 years ago

kaitlynbrown commented 5 years ago

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. https://github.com/jaredpalmer/formik-persist/blob/63aeb8f49eb40a1c79b6887675587f9bde7f2bab/src/formik-persist.tsx#L23-L27 My current workaround is to simply call resetForm() twice. The second time, redux-persist will correctly save the empty form

xxczaki commented 5 years ago

ping @jaredpalmer