File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,37 @@ export default function App() {
8484
8585---
8686
87+ ## \< /> SubmitErrorHandler { #SubmitErrorHandler }
88+
89+ ``` typescript copy
90+ import React from " react"
91+ import { useForm , SubmitHandler , SubmitErrorHandler } from " react-hook-form"
92+
93+ type FormValues = {
94+ firstName: string
95+ lastName: string
96+ email: string
97+ }
98+
99+ export default function App() {
100+ const { register, handleSubmit } = useForm <FormValues >()
101+ const onSubmit: SubmitHandler <FormValues > = (data ) => console .log (data )
102+ const onError: SubmitErrorHandler <FormValues > = (errors ) => console .log (errors );
103+
104+ return (
105+ < form onSubmit = {handleSubmit(onSubmit , onError )}>
106+ < input {... register ("firstName ")} / >
107+ < input {... register ("lastName ")} / >
108+ < input type = " email" {... register ("email ")} / >
109+
110+ < input type = " submit" / >
111+ < / form >
112+ )
113+ }
114+ ```
115+
116+ ---
117+
87118## \< /> Control { #Control }
88119
89120``` typescript copy sandbox="https://codesandbox.io/s/control-2mg07"
You can’t perform that action at this time.
0 commit comments