react-hook-form 7.55.0-next.8 → 7.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2554,8 +2554,15 @@ function useFieldArray(props) {
2554
2554
  React.useEffect(() => {
2555
2555
  !get(control._formValues, name) && control._setFieldArray(name);
2556
2556
  return () => {
2557
- (control._options.shouldUnregister || shouldUnregister) &&
2558
- control.unregister(name);
2557
+ const updateMounted = (name, value) => {
2558
+ const field = get(control._fields, name);
2559
+ if (field && field._f) {
2560
+ field._f.mount = value;
2561
+ }
2562
+ };
2563
+ control._options.shouldUnregister || shouldUnregister
2564
+ ? control.unregister(name)
2565
+ : updateMounted(name, false);
2559
2566
  };
2560
2567
  }, [name, control, keyName, shouldUnregister]);
2561
2568
  return {