react-hook-form: issue: Upgrading from 7.19.5 breaks watch API with useFieldsArray
Version Number
7.20.2
Codesandbox/Expo snack
N/A
Steps to reproduce
Sorry for missing repro link, I may try to dig into it later. I have a fields array containing selectable objects. Prior to 7.20.0, selecting a field would trigger re-render when using the watch() API. This stopped happening after 7.20.0.
Expected behaviour
watch() re-renders when field array changes
What browsers are you seeing the problem on?
No response
Relevant log output
No response
Code of Conduct
- I agree to follow this project’s Code of Conduct
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 24 (13 by maintainers)
There’s a section on
registermethod that mentions the dot vs bracket notation for field names.But, yeah, it doesn’t seem to be mentioned for the controller API (
Controller/useController). Maybe it should be duplicated for the controller as wellHey @bluebill1049! Good news, it seems one of the latest releases fixes this issue! 😃 I still don’t know what was causing it, but can’t reproduce it in 7.24.0 anymore. I tried on 7.20.4 last I think and it was still there, so something fixed it. Thank you!
I have improved the doc with what you suggested above @codelover2k please feel free to send us a PR next time.
https://github.com/react-hook-form/documentation
Is this the warning note about that?
If so, wouldn’t it be better to use something less generic and common as
id? Something likerhf_idor something… I feel like 99% of datasets will haveidas their default unique key, and thus will have the same issue if they miss thiskeynamecollision, like I did.Hi @mfferreira, I tried checking and my
useFieldsArray()doesn’t lose IDs. However, I learned that I can usekeyNameto specify a different key which might come handy (?) Thank you!@bluebill1049 Thanks for the quick reply! I am positive I was on 7.20.2, but I can have another go later. I tried to put together a simple example, but couldn’t reproduce it quickly, so it might be something more intricate