reset & resetField
The defaults are the destination:
resetfor the whole form,resetFieldfor one path. Both wipe state along with values.
- Category
- Return method
- Signatures
reset(nextDefaults?) · resetField(path)- Restores
- value, dirty, touched, errors at scope
- Returns
void
Type into any field to flip it dirty. Click resetField to restore one path; click reset() to restore everything; click reset(newDefaults) to redirect the defaults AND restore in one call. The dirty markers and the form-level pristine/dirty status update reactively as state reset propagates.
reset() restores defaults
form.reset()
Every path goes back to its defaultValues entry, or, where no override was given, to the schema-slim default ('' for strings, 0 for numbers, false for booleans). Alongside the value reset:
dirtyflips false on every leaf.touchedflips false on every leaf.errorsclear at every path.meta.submissionAttempts,meta.submitted, andmeta.submitErrorall zero (the submission surface returns to its initial state).
reset() is the right call after a successful submit when you want the form to look fresh, or when a "Discard changes" button needs to back out unsaved edits.
reset(nextDefaults) redirects defaults
Pass a new defaults object to update the form's defaults AND reset in one step:
form.reset({ name: 'New Default', email: 'new@example.com' })
After this call, the new object IS the form's defaults for any subsequent reset() or resetField call. Useful when the form needs to switch contexts: editing record A then loading record B's values as the new baseline.
The argument is a Partial<DefaultValuesInput<Form>>. Fields you don't mention pick up the previous defaults. Pass {} to reset with no changes to the defaults.
resetField(path) restores one path
form.resetField('email')
Same semantics as reset(), scoped to a single path:
- Value goes back to the path's default.
dirtyandtouchedflip false at that path.- Errors at that path clear.
Useful when one field's been edited but the user wants to discard just that change while keeping the rest of the form's edits in place.
Reset vs clear
reset and resetField go to defaults. clear goes to blank: the schema-slim empty value, skipping defaults. Pick reset when "back to baseline" is the goal; pick clear when "wipe to zero" is.
Where to next
setValuepatterns: write specific values without going through defaults.clear: wipe to blank values, defaults intentionally skipped.- Submit lifecycle: handlers that pair reset with successful submits.