Why keepDefaultValues
option is required for recalculating dirtyFields
on reset?
#13011
Unanswered
SeokminHong
asked this question in
Q&A
Replies: 0 comments
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.
-
react-hook-form/src/logic/createFormControl.ts
Lines 1422 to 1432 in 1b5a674
For the above code, to recalculate
dirtyFields
on reset,keepDefaultValues
is required. Is there any reason for it?I want to implement "dirty on reset". A form is submitted to the server, but the user can continue editing the form while the API request is still in progress. Once the submission completes, the form is reset with the latest values from the API response, but the user's in-progress changes are preserved to accurately track which fields are now dirty.
For now, I'm calling
reset
twice sequently:Beta Was this translation helpful? Give feedback.
All reactions