Form is dirty even though dirtyFields is empty
See original GitHub issueDescribe the bug Form is dirty when it should not be dirty
To Reproduce Steps to reproduce the behavior:
- Focus on first input
- Click elsewhere
- See
isDirty: true
Codesandbox link (Required) https://codesandbox.io/s/react-hook-form-dirty-y7x03?file=/src/App.tsx
Expected behavior
Expected isDirty to be false since nothing is changed and dirtyFields is empty
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:24 (18 by maintainers)
Top Results From Across the Web
React-hook-form doesn't set isDirty to false when back to initial ...
Shouldn't isDirty be set back to false when the form is back to its initial state and dirtyFields should be empty? Is it...
Read more >Remove Dirty Flag When Cell Value Is Changed to Original
An example on how to remove the dirty indicator when the value is put ... If the dirtyFields object is empty, set the...
Read more >useFormState - Simple React forms validation
Dirty fields will not represent as isDirty formState, because dirty fields are marked field dirty at field level rather the entire form.
Read more >Final Form Docs ā `FormState`
dirtyFields. { [string]: boolean }. An object full of booleans, with a value of true for each dirty field. Pristine fields will not...
Read more >API Reference - Formik
<Formik> is a component that helps you with building forms. ... dirty: boolean ... Even if your form is empty by default, you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the same issue, so instead of using isDirty, Iām checking if the dirtyFields object is empty:
if(!isEmpty(dirtyFields)) { "insert code here" }Seems to be working fine
You can build ur own š getValues() and do ur own compare š