Replies: 1 comment
-
|
I'm facing the same issue. Even though the docs suggest to use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using
react-hook-form 7.49.2and ran into an issue whereformState.isDirtydoesn't seem to reflect the user's changes immediately after areset()call — at least not on the first try.What I'm doing:
reset({ ...data })to populate the form from an external source (e.g., editing an item).formState.isDirtyduring form submission to check if the form was changed.But
formState.isDirtyis alwaysfalseon the first submission, even if a field was changed. If I try again (with or without changes),isDirtystarts working correctly.What worked instead
That reliably detects field changes, even after
reset().Am I doing something wrong?
Is this expected behavior for
isDirty? Or should it reflect changes right after a user modifies the form post-reset?I assumed
isDirtyshould becometrueas soon as any field changes from its reset/default value, but maybe there's something I'm missing about how it's tracked internally.I hope someone can clarify this for me. Thanks!
Code
Beta Was this translation helpful? Give feedback.
All reactions