Skip to content

Commit c4b9d5d

Browse files
committed
Added explanation for transformed data type and extended listing
1 parent 6b66f59 commit c4b9d5d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/content/ts.mdx

+4-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export default function App() {
5656

5757
## \</> SubmitHandler {#SubmitHandler}
5858

59+
This type defines the shape of the data that is used in the submit handler. By default the type will be the same as the type used for `useForm` {#UseFormReturn}. When form data gets transformed via resolvers, an additional type is used as the third type parameter for `useForm`. This type should also be used for the submit handler so that the correct shape of the transformed form data is used inside the submit handler.
60+
5961
```typescript copy sandbox="https://codesandbox.io/s/react-hook-form-handlesubmit-ts-v7-z9z0g"
6062
import React from "react"
6163
import { useForm, SubmitHandler } from "react-hook-form"
@@ -129,7 +131,8 @@ export default function App() {
129131
```typescript copy
130132
export type UseFormReturn<
131133
TFieldValues extends FieldValues = FieldValues,
132-
TContext = any
134+
TContext = any,
135+
TTransformedValues extends FieldValues = TFieldValues
133136
> = {
134137
watch: UseFormWatch<TFieldValues>
135138
getValues: UseFormGetValues<TFieldValues>

0 commit comments

Comments
 (0)