Skip to content

Commit a0c8f0b

Browse files
committed
close #1149 subscribe doc correction
1 parent 0cf1437 commit a0c8f0b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/content/docs/useform/subscribe.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Subscribe to form state update without render
44
sidebar: apiLinks
55
---
66

7-
## `subscribe:` <TypeText>`UseFromSubscribe<TFieldValues extends FieldValues>`</TypeText>
7+
## `subscribe:` <TypeText>`UseFormSubscribe<TFieldValues extends FieldValues>`</TypeText>
88

99
Subscribe to [`formState`](/docs/useform/formState) changes and value updates. You can subscribe to individual fields or the entire form, while avoiding unnecessary re-renders caused by form changes.
1010

@@ -15,8 +15,7 @@ Subscribe to [`formState`](/docs/useform/formState) changes and value updates. Y
1515
| Name | Type | Description | Example |
1616
| --------- | --------------------------------------------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1717
| name | <TypeText>undefined</TypeText> | Subscribe to the entire form | `subscribe()` |
18-
| | <TypeText>string</TypeText> | Subscribe on a specific field value by **name** | `subscribe({ name: 'test' })` |
19-
| | <TypeText>string[]</TypeText> | Subscribe on multiple fields by **name**. | `subscribe(['firstName', 'lastName'])` |
18+
| | <TypeText>string[]</TypeText> | Subscribe on multiple fields by **name**. | `subscribe({ name: ['firstName', 'lastName'] })` |
2019
| formState | <TypeText>`Partial<ReadFormState>`</TypeText> | Pick which [`formState`](/docs/useform/formState) to be subscribed. | <CodeArea withOutCopy rawData={`subscribe({ \n formState: { \n values: true, \n isDirty: true, \n dirtyFields: true, \n touchedFields: true, \n isValid: true, \n errors: true, \n defaultValues: true, \n isSubmitted: true \n } \n})`}/> |
2120
| callback | <TypeText>`Function`</TypeText> | The callback function for the subscription. | <CodeArea withOutCopy rawData={`subscribe({ \n formState: { \n values: true \n }, \n callback: ({ values }) => { \n console.log(values) \n } \n})`}/> |
2221
| exact | <TypeText>boolean</TypeText> | This prop will enable an exact match for input name subscriptions. | `subscribe({ name: 'target', exact: true })` |
@@ -61,6 +60,9 @@ export default function App() {
6160
useEffect(() => {
6261
// make sure to unsubscribe;
6362
const callback = subscribe({
63+
formState: {
64+
values: true
65+
},
6466
callback: ({ values }) => {
6567
console.log(values);
6668
}

0 commit comments

Comments
 (0)