react-hook-form 7.21.1-0 → 7.22.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.
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
 
3
3
  var isCheckBoxInput = (element) => element.type === 'checkbox';
4
4
 
@@ -1314,7 +1314,7 @@ function createFormControl(props = {}) {
1314
1314
  : defaultValue));
1315
1315
  return generateWatchOutput(names, _names, fieldValues, isGlobal);
1316
1316
  };
1317
- const _getFieldArray = (name) => get(_stateFlags.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []);
1317
+ const _getFieldArray = (name) => compact(get(_stateFlags.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
1318
1318
  const setFieldValue = (name, value, options = {}) => {
1319
1319
  const field = get(_fields, name);
1320
1320
  let fieldValue = value;
@@ -1673,14 +1673,14 @@ function createFormControl(props = {}) {
1673
1673
  const reset = (formValues, keepStateOptions = {}) => {
1674
1674
  const updatedValues = formValues || _defaultValues;
1675
1675
  const cloneUpdatedValues = cloneObject(updatedValues);
1676
- const values = !isEmptyObject(formValues)
1676
+ const values = formValues && !isEmptyObject(formValues)
1677
1677
  ? cloneUpdatedValues
1678
1678
  : _defaultValues;
1679
1679
  if (!keepStateOptions.keepDefaultValues) {
1680
1680
  _defaultValues = updatedValues;
1681
1681
  }
1682
1682
  if (!keepStateOptions.keepValues) {
1683
- if (isWeb) {
1683
+ if (isWeb && isUndefined(formValues)) {
1684
1684
  for (const name of _names.mount) {
1685
1685
  const field = get(_fields, name);
1686
1686
  if (field && field._f) {