Capítulo 17 de 39
resetDefaultValues(values, options?) (7.77.0+) advances the form's internal baseline for dirty-tracking without touching what the user currently has typed — useful for "advance the baseline to the just-saved values so only further edits count as dirty" after an async submission.
dirtyFields/isDirty.dirtyFields as-is instead of recomputing against the new baseline.isValid stays as it was.!isDirty — after a successful async save, call resetDefaultValues(savedData) so the button re-disables until the next real edit, instead of staying enabled because the form still looks "dirty" against the pre-submit baseline.const onSubmit = async (data) => {
await saveToServer(data)
resetDefaultValues(data) // baseline advances; isDirty only true for edits after this point
}
<button type="submit" disabled={!isDirty}>Save</button>
reset(data) instead when you only want to move the baseline: reset also touches current form values/subscriptions; resetDefaultValues is the narrower, values-preserving tool.resetDefaultValues changes what "dirty" is measured against, not what's currently in the form.isDirty.isDirty/dirtyFields live.