Skip to content

issue: useFieldArray cut off null values from array and cause broken indexing next entities #12076

@dzwiedziu-nkg

Description

@dzwiedziu-nkg

Version Number

7.52.1

Codesandbox/Expo snack

https://codesandbox.io/s/react-hook-form-usefieldarray-nested-arrays-forked-6jn6cm?file=/src/index.js

Steps to reproduce

I add null values to array in defaultValues. useFieldArray cut off null values from array. So indexing of is invalid. We get only two array elements with broken index.

Its happen because you wrap by compact function in this:

Expected behaviour

When you change react-hook-form version to 7.12.2 in packages.json this example works good. We get all array elements with correct index.

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions