react-hook-form: fields from useFieldArray with init values not working in 6.4.0 but in v. 5.7.2

Describe the bug I’m using fields from the useFieldArray method which is initialized with default values.

However in v. 5.7.2 the default values are showing up but not in v. 6.4.0

To Reproduce Look in the Sandbox:

v. 6.4.0 (not working) Edit recursing-cerf-sgk4m

v. 5.7.2 (working) Edit epic-ride-3rxbk

Codesandbox link (Required) see above

Expected behavior like in v. 5.7.2 show up init variables

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

Thanks for the detail, but you will need to supply defaultValue. It’s uncontrolled input and to avoid other related bugs.

Fair enough. I guess I can just pass in an amount which can be undefined. If defaultValue is undefined and the input is not in a useFieldArray it will use the value in defaultValues provided with useForm, correct?

what about empty string ''?

I was thinking something like this: https://codesandbox.io/s/charming-golick-oz1oe?file=/src/Transactions.js

It seems to work. Then I can get around it by creating my own context with the defaultValues.

Thanks for a great library!