Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-hook-form - how to reset formState.isDirty after form submitting

as I wrote in the title, please give me a hint on how to reset isDirty field from formState object.

In my application, I have a 'save' button which is disabled by default. When I change the value of any input the button is set to enabled because isDirty state is changed to true. After a successful save action, I want to make my save button disabled again (so I need to set isDirty as false again).

like image 536
Emil Buszyło Avatar asked Oct 14 '25 18:10

Emil Buszyło


1 Answers

After successful form submission, you can reset form to its original state using reset from useForm hook. This will reset formState and isDirty value will be false.

Docs: https://react-hook-form.com/docs/useform/reset

like image 95
Sreekar Avatar answered Oct 18 '25 04:10

Sreekar