-
I'm really confused.
The following is available in the context:
Why does scenario 2 below rerender all the time? In scenario 1, I'm using The simple solution is of course to use
Scenario 1:
Scenario 2:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Whenever you're subscribed to root level state like
You don't always want to wrap fields in a component to access some nested field's value at top form level. Example CSB |
Beta Was this translation helpful? Give feedback.
-
=================== ✅ useWatch vs watch in React Hook Form ============================ Performance-friendly: Ideal for large forms where you only want to re-render specific components based on certain field changes.
Better for one-time reads (e.g., inside useEffect) but not for reactive rendering. Not scoped, so it listens globally inside the form context. 🔁 Important Note About Using in useEffect So: ie
ie
❌ Wrong Pattern (reactive dependencies cause infinite loop)
✅ Correct pattern with useWatch:
|
Beta Was this translation helpful? Give feedback.
Whenever you're subscribed to root level state like
formState
, form values (watch
)You can always consider hooks alternatives like
useFormState
, useWatch.You don't always want to wrap fields in a component to access some nested field's value at top form level.
Example CSB
You can switch on component render highlights in devtools for convenience