react-hook-form: How to reset dirty or reinitialize form? dirty never false after call reset()
Describe the bug Dirty is not reset after call reset().
To Reproduce Here is codesandbox for reproduce: https://codesandbox.io/embed/smoosh-shape-fuy5e
- There is
SampleFormcomponent to receiveuserandonSubmitprops. it useuseEffect()hook(line 15 ~ 18) for reset form whenprops.useris updated. but currently, I commentedreset(user)(line 17) for reproduce. - change some fields, and reset original value. the submit button’s disabled is toggle via
formState.dirty(ex> Update name to Foo1, submit is enabled. Update name to Foo, submit is disabled) - uncomment
SampleFormline 17,reset(dirty)line. and try again step 2. the submit button is never disabled again even I tried set original value.
Expected behavior
formState.dirty should be false when I change form value to original after call reset()
Screenshots
App.tsx

SampleForm.tsx:
(Ignore Rocket’s popup… 😉)
Desktop (please complete the following information):
- OS: MacOS 10.14.16 mojave
- Browser: Chrome
- Version: 76.0.3809.132
- react-hook-form@3.23.4
Additional context
Maybe it is not a bug. but I want to reset dirty value after I call reset(). Is there another way to reset dirty? Thanks to your awesome library 😃
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 16 (8 by maintainers)
working on my end, if you can verify. we can release this fix soon 😃 ❤️
omg, blazing fast! I will check out your works!
Here you go https://codesandbox.io/s/suspicious-cori-fd354. I was able to narrow it down to only happening when I use Material UI components. I don’t know if that’s something you really want to support though.
I will publish this patch 😃 happy coding ❤️ thanks for pick up this issue too 😃
Good! I tested on codesandbox, and my production! thanks to your works! ⚡️I have to close issue!
want to test out this patched beta version:
react-hook-form@3.23.5-beta.1?Thanks for the detailed issue report. I will take a look this issue soon 😃