File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
src/09-external-libraries Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ const Example1 = () => {
3737 */
3838
3939const Example2 = ( ) => {
40- const form = useForm ( { } ) ;
40+ const form = useForm ( ) ;
4141
4242 return (
4343 < form
Original file line number Diff line number Diff line change 1+ import { FieldValues , useForm } from "react-hook-form" ;
2+ import { Equal , Expect } from "../helpers/type-utils" ;
3+
4+ const Example1 = ( ) => {
5+ const form = useForm ( {
6+ values : {
7+ firstName : "" ,
8+ lastName : "" ,
9+ } ,
10+ } ) ;
11+
12+ return (
13+ < form
14+ onSubmit = { form . handleSubmit ( ( values ) => {
15+ type test = Expect <
16+ Equal < typeof values , { firstName : string ; lastName : string } >
17+ > ;
18+ } ) }
19+ >
20+ < input { ...form . register ( "firstName" ) } />
21+ < input { ...form . register ( "lastName" ) } />
22+ </ form >
23+ ) ;
24+ } ;
25+
26+ const Example2 = ( ) => {
27+ const form = useForm ( ) ;
28+
29+ return (
30+ < form
31+ onSubmit = { form . handleSubmit ( ( values ) => {
32+ type test = Expect < Equal < typeof values , FieldValues > > ;
33+ } ) }
34+ >
35+ < input { ...form . register ( "firstName" ) } />
36+ < input { ...form . register ( "lastName" ) } />
37+ </ form >
38+ ) ;
39+ } ;
You can’t perform that action at this time.
0 commit comments