Skip to content

Commit 28baceb

Browse files
docs: correct setValues callback return type to TFieldValues (#1214)
1 parent ebe0c73 commit 28baceb

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/content/docs/useform/setvalues.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ metaDescription: Update multiple React Hook Form field values at once using an o
55
sidebar: apiLinks
66
---
77

8-
## \</> `setValues:` <TypeText>(value: Partial\<TFieldValues\> | ((data: TFieldValues) => Partial\<TFieldValues\>), options?: SetValueConfig) => void</TypeText>
8+
## \</> `setValues:` <TypeText>(value: Partial\<TFieldValues\> | ((formValues: TFieldValues) => TFieldValues), options?: SetValueConfig) => void</TypeText>
99

1010
This function allows you to dynamically set multiple field values at once and have the options to validate and update the form state. It also accepts a callback function that receives the current form values, making it easy to derive the next state from the existing one.
1111

1212
### Props
1313

1414
---
1515

16-
| Name | | Description |
17-
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18-
| `value`<br/><TypeText>Partial\<TFieldValues\> \| (data: TFieldValues) => Partial\<TFieldValues\></TypeText> | | An object containing the field values to update, or a callback function that receives the current form values and returns the updated values. This argument is required. |
19-
| `options` | `shouldValidate`<br/><TypeText>boolean</TypeText> | <ul><li>Whether to compute if your input is valid or not (subscribed to <TypeText>errors</TypeText>).</li><li>Whether to compute if your entire form is valid or not (subscribed to <TypeText>isValid</TypeText>).</li></ul> |
20-
| | `shouldDirty`<br/><TypeText>boolean</TypeText> | <ul><li>Whether to compute if your input is dirty or not against your `defaultValues` (subscribed to <TypeText>dirtyFields</TypeText>).</li><li>Whether to compute if your entire form is dirty or not against your `defaultValues` (subscribed to <TypeText>isDirty</TypeText>).</li></ul> |
21-
| | `shouldTouch`<br/><TypeText>boolean</TypeText> | Whether to set the updated inputs to be touched. |
16+
| Name | | Description |
17+
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
18+
| `value`<br/><TypeText>Partial\<TFieldValues\> \| (formValues: TFieldValues) => TFieldValues</TypeText> | | An object containing the field values to update, or a callback function that receives the current form values and returns the next form values. This argument is required. |
19+
| `options` | `shouldValidate`<br/><TypeText>boolean</TypeText> | <ul><li>Whether to compute if your input is valid or not (subscribed to <TypeText>errors</TypeText>).</li><li>Whether to compute if your entire form is valid or not (subscribed to <TypeText>isValid</TypeText>).</li></ul> |
20+
| | `shouldDirty`<br/><TypeText>boolean</TypeText> | <ul><li>Whether to compute if your input is dirty or not against your `defaultValues` (subscribed to <TypeText>dirtyFields</TypeText>).</li><li>Whether to compute if your entire form is dirty or not against your `defaultValues` (subscribed to <TypeText>isDirty</TypeText>).</li></ul> |
21+
| | `shouldTouch`<br/><TypeText>boolean</TypeText> | Whether to set the updated inputs to be touched. |
2222

2323
<Admonition type="important" title="Rules">
2424

25-
- When using the callback form, the function receives a snapshot of the current form values and should return only the fields you want to update.
25+
- When using the callback form, the function receives a snapshot of the current form values and should return the next form values.
2626

2727
- This method does not reset the form. Use [`reset`](/docs/useform/reset) if you need to reinitialize `defaultValues`.
2828

0 commit comments

Comments
 (0)