Skip to content

Commit 494c51b

Browse files
docs: clarify useFormContext formState subscriptions
1 parent 89acbf0 commit 494c51b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/content/docs/useformcontext.mdx

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

3945
**Example:**

0 commit comments

Comments
 (0)