react-hook-form 7.19.1 → 7.19.2

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.
package/dist/index.esm.js CHANGED
@@ -261,7 +261,7 @@ function useController(props) {
261
261
  if (isNameInFieldArray(control._names.array, name)
262
262
  ? _shouldUnregisterField && !control._stateFlags.action
263
263
  : _shouldUnregisterField) {
264
- control.unregister(name);
264
+ control.unregister(name, { keepDefaultValue: true });
265
265
  }
266
266
  else {
267
267
  updateMounted(name, false);
@@ -1585,7 +1585,9 @@ function createFormControl(props = {}) {
1585
1585
  e.persist && e.persist();
1586
1586
  }
1587
1587
  let hasNoPromiseError = true;
1588
- let fieldValues = Object.assign({}, _formValues);
1588
+ let fieldValues = _options.shouldUnregister
1589
+ ? cloneObject(_formValues)
1590
+ : Object.assign({}, _formValues);
1589
1591
  _subjects.state.next({
1590
1592
  isSubmitting: true,
1591
1593
  });
@@ -1843,7 +1845,6 @@ function useForm(props = {}) {
1843
1845
  }
1844
1846
  control._removeUnmounted();
1845
1847
  });
1846
- React.useEffect(() => () => Object.values(control._subjects).forEach((subject) => subject.unsubscribe()), [control]);
1847
1848
  _formControl.current.formState = getProxyFormState(formState, control._proxyFormState);
1848
1849
  return _formControl.current;
1849
1850
  }