Describe the bug
Form is registering non registered array fields with indexes.
To Reproduce
Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/react-hook-form-usefieldarray-nested-arrays-forked-qc13y
- Enter inputs
- Click submit query
- See concole
Codesandbox link (Required)
https://codesandbox.io/s/react-hook-form-usefieldarray-nested-arrays-forked-qc13y
- useForm Template
- useFieldArray Template
- Controller Template
Expected behavior
There are too many empty fields, it should not exist.
Desktop (please complete the following information):
- OS: MacOS BigSur 11.2.3
- Browser Firefox Developer Edition
- Version 87.0b8 (64-bit)
Smartphone (please complete the following information):
didn’t test on smartphone
Additional context
N/A
I just want only fields that has been registered, why it is registiring automatically non registered fields?
Looks like you are not using it correctly. Please checkout my solution which uses useForm and useFieldArray to load the values from myInputes.
https://codesandbox.io/s/react-hook-form-usefieldarray-nested-arrays-forked-5gz28?file=/src/index.js
thanks @kpnigalye👍
It would be the same.
the important part is not to overwrite the
id
fromuseFieldArray
, you can host your own field array id by changing thekeyName
in the config and store your ownid
in the hidden input.hope above make sense.