Formik: [v2] calling resetForm({values}) with nested objects won't reset dirty and isValid state to false

Created on 31 Oct 2019  路  5Comments  路  Source: formium/formik

馃悰 Bug report

Current Behavior

If you are calling resetForm({values}) with values of nested objects the dirty and isValid state is still true.

Expected behavior

As in v1 dirty and isValid state should be false after calling resetForm({values}) with the new values.

Reproducible example

v1.5.8: https://codesandbox.io/s/formik-codesandbox-template-tkqcc
v2.0.3: https://codesandbox.io/s/formik-codesandbox-template-076j5

Suggested solution(s)

Additional context

Your environment

| Software | Version(s) |
| ---------------- | ---------- |
| Formik | 2.0.3
| React | 16.11.0

Most helpful comment

Any updates on this one ? how to workaround the dirty set to true even after resetForm({values}) ?

All 5 comments

Does the sandbox show the isValid issue as well? I wasn't sure how to reproduce it. I've created pull request #1986 to solve the dirty part at least.

I just noticed that the isValid state is also true. And in v1 it is false. The sandbox should show it. Don't know if it is intended so?
Thanks for your work! 馃憦

I'm also experiencing this issue. I tested the PR @Tigge has open, and can verify it fixes the issue.

@simmco for isValid I think this is to be expected in version 2. The isInitialValid (which defaulted to false) is now deprecated, and replaced with initialErrors (which defaults to {}, meaning no errors).

This is a good change, and while isInitialValid is deprecated but still usable in version 2, so you can get the same behaviour by setting it to false. But if you want to start with an invalid form it is better to set initialErrors instead.

Any updates on this one ? how to workaround the dirty set to true even after resetForm({values}) ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

najisawas picture najisawas  路  3Comments

najisawas picture najisawas  路  3Comments

Jucesr picture Jucesr  路  3Comments

jaredpalmer picture jaredpalmer  路  3Comments

Jungwoo-An picture Jungwoo-An  路  3Comments