Skip to content

Commit 847f8f0

Browse files
committed
add SubmitErrorHandler type to handleSubmit example
1 parent fc376e8 commit 847f8f0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/content/docs/useform/handlesubmit.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ This function will receive the form data if form validation is successful.
5656

5757
```typescript copy sandbox="https://codesandbox.io/s/react-hook-form-handlesubmit-ts-v7-lcrtu"
5858
import React from "react"
59-
import { useForm, SubmitHandler } from "react-hook-form"
59+
import { useForm, SubmitHandler, SubmitErrorHandler } from "react-hook-form"
6060

6161
type FormValues = {
6262
firstName: string
@@ -67,6 +67,7 @@ type FormValues = {
6767
export default function App() {
6868
const { register, handleSubmit } = useForm<FormValues>()
6969
const onSubmit: SubmitHandler<FormValues> = (data) => console.log(data)
70+
const onError: SubmitErrorHandler<FormValues> = (errors) => console.log(errors)
7071

7172
return (
7273
<form onSubmit={handleSubmit(onSubmit)}>

0 commit comments

Comments
 (0)