Resetting forms
Resetting a form is not only about values — it also affects errors and meta state.
Formora provides a single, explicit reset API that resets the entire form in a predictable way.
reset()
reset() restores the form back to its initial state.
form.reset();
What reset() does
Calling reset() will:
- reset all values back to
initialValues - clear all validation errors
- clear
touchedstate - clear
dirtystate
After a reset, the form behaves as if it was freshly mounted.
Example: reset after successful submit
A common pattern is to reset the form after a successful submit.
<form
onSubmit={form.handleSubmit(async (values) => {
await save(values);
form.reset();
})}
>
<button type="submit">Save</button>
</form>
Example: manual reset button
You can also expose a reset button to the user.
<button type="button" onClick={() => form.reset()}>
Reset
</button>
Resetting nested data
Because reset() restores the entire form to initialValues, all nested data is reset automatically.
// initialValues
{
profile: {
name: "",
address: {
street: "",
},
},
}
// after reset()
{
profile: {
name: "",
address: {
street: "",
},
},
}
There is currently no per-field or partial reset API.
Common mistakes
Do not try to manually clear parts of form.values, form.errors, or meta state.
Always use reset() to return the form to a clean state.
Summary
reset()is the only reset API- it resets values, errors, touched, and dirty state
- nested data is reset automatically
- partial or per-field resets are not supported yet
This explicit behavior keeps reset logic predictable and easy to reason about.