react-hook-form 7.51.5 → 7.52.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.
@@ -417,7 +417,7 @@ function useController(props) {
417
417
  const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
418
418
  const updateMounted = (name, value) => {
419
419
  const field = get(control._fields, name);
420
- if (field) {
420
+ if (field && field._f) {
421
421
  field._f.mount = value;
422
422
  }
423
423
  };
@@ -1679,7 +1679,9 @@ function createFormControl(props = {}) {
1679
1679
  const output = {
1680
1680
  name,
1681
1681
  };
1682
- const disabledField = !!(get(_fields, name) && get(_fields, name)._f.disabled);
1682
+ const disabledField = !!(get(_fields, name) &&
1683
+ get(_fields, name)._f &&
1684
+ get(_fields, name)._f.disabled);
1683
1685
  if (!isBlurEvent || shouldDirty) {
1684
1686
  if (_proxyFormState.isDirty) {
1685
1687
  isPreviousDirty = _formState.isDirty;
@@ -2039,9 +2041,9 @@ function createFormControl(props = {}) {
2039
2041
  const getFieldState = (name, formState) => ({
2040
2042
  invalid: !!get((formState || _formState).errors, name),
2041
2043
  isDirty: !!get((formState || _formState).dirtyFields, name),
2042
- isTouched: !!get((formState || _formState).touchedFields, name),
2043
- isValidating: !!get((formState || _formState).validatingFields, name),
2044
2044
  error: get((formState || _formState).errors, name),
2045
+ isValidating: !!get(_formState.validatingFields, name),
2046
+ isTouched: !!get((formState || _formState).touchedFields, name),
2045
2047
  });
2046
2048
  const clearErrors = (name) => {
2047
2049
  name &&
@@ -2366,7 +2368,9 @@ function createFormControl(props = {}) {
2366
2368
  : _formState.dirtyFields
2367
2369
  : keepStateOptions.keepDefaultValues && formValues
2368
2370
  ? getDirtyFields(_defaultValues, formValues)
2369
- : {},
2371
+ : keepStateOptions.keepDirty
2372
+ ? _formState.dirtyFields
2373
+ : {},
2370
2374
  touchedFields: keepStateOptions.keepTouched
2371
2375
  ? _formState.touchedFields
2372
2376
  : {},