react-hook-form 7.41.0 → 7.41.1

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
  });
@@ -1650,7 +1649,7 @@ function createFormControl(props = {}, flushRootRender) {
1650
1649
  : isString(names)
1651
1650
  ? { [names]: defaultValue }
1652
1651
  : defaultValue),
1653
- }, isGlobal);
1652
+ }, isGlobal, defaultValue);
1654
1653
  const _getFieldArray = (name) => compact(get(_stateFlags.mount ? _formValues : _defaultValues, name, props.shouldUnregister ? get(_defaultValues, name, []) : []));
1655
1654
  const setFieldValue = (name, value, options = {}) => {
1656
1655
  const field = get(_fields, name);
@@ -1798,14 +1797,9 @@ function createFormControl(props = {}, flushRootRender) {
1798
1797
  isValid = await executeBuiltInValidation(_fields, true);
1799
1798
  }
1800
1799
  }
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
- }
1800
+ field._f.deps &&
1801
+ trigger(field._f.deps);
1802
+ shouldRenderByError(name, isValid, error, fieldState);
1809
1803
  }
1810
1804
  };
1811
1805
  const trigger = async (name, options = {}) => {