nested value disappear when remount NestedFieldArray

Describe the bug
I have a nested array form, and some components need to be hidden when show flag is false.
The form will remove component when show is false, and mount component when flag is true.
It is perfect at the first level field array. However, in nested-field-array, we lose the default values after we re mount it.

I am not sure it is a bug or I misunderstood the correct way. 😭
Please help me!

To Reproduce
Steps to reproduce the behavior:

  1. Go to code sandbox link
  2. Click “show” checkbox in first level
  3. See our nested array components.
  4. Click test1’s “show” checkbox.
  5. See test1’s children(nested field array)
  6. Click test1’s “show” checkbox.
  7. Hidden test1’s children(nested field array)
  8. Click test1’s “show” checkbox.
  9. LOL… We can not see the test1’s children(nested field array)

Codesandbox link (Required)
Include a codesandbox will help us to investigate the issue quicker.
https://codesandbox.io/s/react-hook-form-nestedarray-empty-issue-fpolt?file=/src/Item.js

Expected behavior

  1. Go to code sandbox link
  2. Click “show” checkbox in first level
  3. See our nested array components.
  4. Click test1’s “show” checkbox.
  5. See test1’s children(nested field array)
  6. Click test1’s “show” checkbox.
  7. Hidden test1’s children(nested field array)
  8. Click test1’s “show” checkbox.
  9. See the test1’s children(nested field array)

Screenshots
If applicable, add screenshots to help explain your problem.
螢幕錄製 2021-03-13 下午3 06 57

Desktop (please complete the following information):

  • OS: macOS Big Sur 11.0.1
  • Browser: Safari 14.0.1
  • React Hook Form Version: 16.15.4

Additional context
I am not sure it is a bug or I misunderstood the correct way. 😭
IMO, I should get defaultValue when mount a fieldArray component. And it works on the version 6.14.2
https://codesandbox.io/s/react-hook-form-nestedarray-empty-issue16142-wrznk?file=/src/Item.js

2 thoughts on “nested value disappear when remount NestedFieldArray