Skip to content

Commit 17ecb3f

Browse files
docs: clarify useFormContext formState subscriptions (#1197)
* docs: clarify useFormContext formState subscriptions * docs: format useFormContext note --------- Co-authored-by: hiromieguchi802-lab <hiromieguchi802-lab@users.noreply.github.com> Co-authored-by: hiromieguchi802-lab <270042125+hiromieguchi802-lab@users.noreply.github.com>
1 parent 11e7c77 commit 17ecb3f

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/content/docs/useformcontext.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ const methods = useFormContext() // retrieve those props
3535
<Admonition type="important" title="Rules">
3636
You need to wrap your form with the [`FormProvider`](/docs/formprovider)
3737
component for `useFormContext` to work properly.
38+
39+
If you need to subscribe to form state values like `errors`, `isDirty`, or
40+
`dirtyFields` inside a `FormProvider` tree, use
41+
[`useFormState`](/docs/useformstate) instead of destructuring `formState`
42+
from `useFormContext()`. `formState` is wrapped with a Proxy, so you should
43+
read the specific state you want to subscribe to before render.
44+
3845
</Admonition>
3946

4047
**Example:**

0 commit comments

Comments
 (0)