react-hook-form 7.41.0 → 7.41.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.
@@ -256,10 +256,10 @@ function useFormState(props) {
256
256
 
257
257
  var isString = (value) => typeof value === 'string';
258
258
 
259
- var generateWatchOutput = (names, _names, formValues, isGlobal) => {
259
+ var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
260
260
  if (isString(names)) {
261
261
  isGlobal && _names.watch.add(names);
262
- return get(formValues, names);
262
+ return get(formValues, names, defaultValue);
263
263
  }
264
264
  if (Array.isArray(names)) {
265
265
  return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));
@@ -330,8 +330,7 @@ function useWatch(props) {
330
330
  subject: control._subjects.watch,
331
331
  next: (formState) => {
332
332
  if (shouldSubscribeByName(_name.current, formState.name, exact)) {
333
- const fieldValues = generateWatchOutput(_name.current, control._names, formState.values || control._formValues);
334
- updateValue(isUndefined(fieldValues) ? defaultValue : cloneObject(fieldValues));
333
+ updateValue(cloneObject(generateWatchOutput(_name.current, control._names, formState.values || control._formValues, false, defaultValue)));
335
334
  }
336
335
  },
337
336
  });
@@ -677,6 +676,7 @@ var validateField = async (field, inputValue, validateAllFieldCriteria, shouldUs
677
676
  isUndefined(ref.value) &&
678
677
  isUndefined(inputValue)) ||
679
678
  inputValue === '' ||
679
+ ref.value === '' ||
680
680
  (Array.isArray(inputValue) && !inputValue.length);
681
681
  const appendErrorsCurry = appendErrors.bind(null, name, validateAllFieldCriteria, error);
682
682
  const getMinMaxMessage = (exceedMax, maxLengthMessage, minLengthMessage, maxType = INPUT_VALIDATION_RULES.maxLength, minType = INPUT_VALIDATION_RULES.minLength) => {
@@ -1650,7 +1650,7 @@ function createFormControl(props = {}, flushRootRender) {
1650
1650
  : isString(names)
1651
1651
  ? { [names]: defaultValue }
1652
1652
  : defaultValue),
1653
- }, isGlobal);
1653
+ }, isGlobal, defaultValue);
1654
1654
  const _getFieldArray = (name) => compact(get(_stateFlags.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
1655
1655
  const setFieldValue = (name, value, options = {}) => {
1656
1656
  const field = get(_fields, name);
@@ -1798,14 +1798,9 @@ function createFormControl(props = {}, flushRootRender) {
1798
1798
  isValid = await executeBuiltInValidation(_fields, true);
1799
1799
  }
1800
1800
  }
1801
- if (!isPrimitive(fieldValue) || getCurrentFieldValue() === fieldValue) {
1802
- field._f.deps &&
1803
- trigger(field._f.deps);
1804
- shouldRenderByError(name, isValid, error, fieldState);
1805
- }
1806
- else {
1807
- _updateIsValidating(false);
1808
- }
1801
+ field._f.deps &&
1802
+ trigger(field._f.deps);
1803
+ shouldRenderByError(name, isValid, error, fieldState);
1809
1804
  }
1810
1805
  };
1811
1806
  const trigger = async (name, options = {}) => {