79376359

Date: 2025-01-22 01:54:14
Score: 0.5
Natty:
Report link

I'll try to expand the topic.. after we all come here for this.


In simple language:

watch - like taking a quick peek at your notebook. You open, you look, you close. For example: "What's ur favourite color?", you say Blue. But if you change it to Red, i'll have to open the notebook again. ( snapshop )

useWatch - like a helper that all he does is looking at the values, once the values change, the helper shouts the value.


In our language:

watch - Pull mechanism.

useWatch - Push mechanism.


Bottom line...

When performance is critical - watch to avoid rerenders.

For complex ( form in form, dynamic fields etc... ) - useWatch to maintain synced state

react-hook-forms is actually a very good choice! But in order to really master it ( or at least answer the 'how' or 'why it workes so fast' ) you should check the JS proxies and Controlled vs UnControlled components in react, refs, this is the root of RHF.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: Vladimir Yel