Skip to content

Commit 21047ab

Browse files
committed
Changed to P/S
1 parent 716502d commit 21047ab

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/09-external-libraries/73-react-hook-form.explainer.tsx renamed to src/09-external-libraries/73-react-hook-form.problem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const Example1 = () => {
3737
*/
3838

3939
const Example2 = () => {
40-
const form = useForm({});
40+
const form = useForm();
4141

4242
return (
4343
<form
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
};

0 commit comments

Comments
 (0)