You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of v2.1.4, initialValues cannot be counted on to not change during the duration of a page load. These lines introduced in v2.1.4 will now update initialValuesanytime the props.initialValues changes. Therefore if I have an application and the initialValues I pass in happen to change then Formik will update that in its internal state and therefore when doing things like determining if a form is dirty it can report unexpected results.
Expected behavior
I would expect once I pass in initialValues for those to be set throughout the life of the page (as this is how it has worked previously).
Input a single letter into the name field (dirty = true)
Input a single letter into the email field (dirty = true)
Then remove (backspace) the value you just entered in the email field.
Notice that in Formik state dirty = false because initialValues are equal to values.
If you switch the Formik version back to 2.1.3 the above test case end with dirty = true in step 4.
Suggested solution(s)
Remove this code which was introduced in the 2.1.4 release. It was introduced via #2205
Additional context
If this new functionality is to be expected and desired then I believe this should be a new minor version bump since it is a breaking change.
Your environment
Software
Version(s)
Formik
2.1.4
React
16.11.0
TypeScript
n/a
Browser
Chrome 80
npm/Yarn
Yarn
Operating System
Mac OS
The text was updated successfully, but these errors were encountered:
jamesmosier
changed the title
initialValues being reset causing dirty to be incorrect (v2.1.4 bug)
initialValues being reset causing dirty to be incorrect (v2.1.4 regression)
Feb 18, 2020
🐛 Bug report
Current Behavior
As of v2.1.4,
initialValues
cannot be counted on to not change during the duration of a page load. These lines introduced inv2.1.4
will now updateinitialValues
anytime theprops.initialValues
changes. Therefore if I have an application and theinitialValues
I pass in happen to change then Formik will update that in its internal state and therefore when doing things like determining if a form is dirty it can report unexpected results.Expected behavior
I would expect once I pass in
initialValues
for those to be set throughout the life of the page (as this is how it has worked previously).Reproducible example
https://codesandbox.io/s/formik-v214-dirty-breaking-2y6ho
name
field (dirty = true
)email
field (dirty = true
)email
field.dirty = false
becauseinitialValues
are equal tovalues
.If you switch the Formik version back to
2.1.3
the above test case end withdirty = true
in step 4.Suggested solution(s)
Remove this code which was introduced in the
2.1.4
release. It was introduced via #2205Additional context
If this new functionality is to be expected and desired then I believe this should be a new minor version bump since it is a breaking change.
Your environment
The text was updated successfully, but these errors were encountered: