handleSubmit:
((data: Object, e?: Event) => void, (errors: Object, e?: Event) => void) => Function
This function will receive the form data if form validation is successful.
Props
Name | Type | Description |
---|---|---|
SubmitHandler | (data: Object, e?: Event) => void | A successful callback. |
SubmitErrorHandler | (errors: Object, e?: Event) => void | An error callback. |
Rules
You can easily submit form asynchronously with handleSubmit.
disabled
inputs will appear asundefined
values in form values. If you want to prevent users from updating an input and wish to retain the form value, you can usereadOnly
or disable the entire <fieldset />. Here is an example.During the callback, if the function itself throws an error inside of
handleSubmit
, it will not swallow the error itself but bubble it up instead andisSubmitSuccessful
will be remained asfalse
.
Examples
Video
The following video tutorial explains the handleSubmit
API in detail.
Thank you for your support
If you find React Hook Form to be useful in your project, please consider to star and support it.