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

  1. There is SampleForm component to receive user and onSubmit props. it use useEffect() hook(line 15 ~ 18) for reset form when props.user is updated. but currently, I commented reset(user)(line 17) for reproduce.
  2. 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)
  3. uncomment SampleForm line 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 image

SampleForm.tsx: 2019-09-09 14-10-15 2019-09-09 14_11_13 (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)

Most upvoted comments

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!

2019-09-09 15-17-10 2019-09-09 15_17_24

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 😃