Skip to content

Commit

Permalink
Added explanation for transformed data type and extended listing
Browse files Browse the repository at this point in the history
  • Loading branch information
maurer2 committed Aug 18, 2024
1 parent 6b66f59 commit c4b9d5d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/content/ts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export default function App() {

## \</> SubmitHandler {#SubmitHandler}

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.

```typescript copy sandbox="https://codesandbox.io/s/react-hook-form-handlesubmit-ts-v7-z9z0g"
import React from "react"
import { useForm, SubmitHandler } from "react-hook-form"
Expand Down Expand Up @@ -129,7 +131,8 @@ export default function App() {
```typescript copy
export type UseFormReturn<
TFieldValues extends FieldValues = FieldValues,
TContext = any
TContext = any,
TTransformedValues extends FieldValues = TFieldValues
> = {
watch: UseFormWatch<TFieldValues>
getValues: UseFormGetValues<TFieldValues>
Expand Down

0 comments on commit c4b9d5d

Please sign in to comment.