react-hook-form: issue: reset with fieldArray does not work correctly in a certain scenario

Version Number

7.33.1

Codesandbox/Expo snack

https://codesandbox.io/s/async-violet-tvqg3p

Steps to reproduce

  1. Open sandbox console.
  2. Click “Submit”

or:

  1. Change the “catch phrase” value
  2. click “submit”

Expected behaviour

The form should reset with the values returned by the “server”. Instead, it will revert to the original form’s default value ONLY for the field array.

The documentation encourages using reset within useEffect. However, sometimes using useEffect is very inconvenient.

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (13 by maintainers)

Most upvoted comments

Thanks, guys, I will get a PR up for the fix over the weekend anyhow, we can take our time on publishing the fix.

I also am confused why this would unregister in this case.

reset does remove all input references, which will need to get all inputs re-register again which will re-run useEffect and this all complicates thing on determined if input is “really” unmounted, so this is consider a design flaw.

@Moshyfawn it’s all related to useEffect when it’s get fired

@bluebill1049 in my example sandbox, why would the unregister logic trigger? It’s not being unmounted.