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
- Open sandbox console.
- Click “Submit”
or:
- Change the “catch phrase” value
- 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)
Thanks, guys, I will get a PR up for the fix over the weekend anyhow, we can take our time on publishing the fix.
reset does remove all input references, which will need to get all inputs re-register again which will re-run
useEffectand this all complicates thing on determined if input is “really” unmounted, so this is consider a design flaw.@Moshyfawn it’s all related to
useEffectwhen it’s get fired@bluebill1049 in my example sandbox, why would the unregister logic trigger? It’s not being unmounted.