react-hook-form 7.43.8 → 7.43.9

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.
@@ -1095,12 +1095,15 @@ function useFieldArray(props) {
1095
1095
  if (control._options.resolver) {
1096
1096
  control._executeSchema([name]).then((result) => {
1097
1097
  const error = get(result.errors, name);
1098
- error
1099
- ? set(control._formState.errors, name, error)
1100
- : unset(control._formState.errors, name);
1101
- control._subjects.state.next({
1102
- errors: control._formState.errors,
1103
- });
1098
+ const existingError = get(control._formState.errors, name);
1099
+ if (existingError ? !error && existingError.type : error && error.type) {
1100
+ error
1101
+ ? set(control._formState.errors, name, error)
1102
+ : unset(control._formState.errors, name);
1103
+ control._subjects.state.next({
1104
+ errors: control._formState.errors,
1105
+ });
1106
+ }
1104
1107
  });
1105
1108
  }
1106
1109
  else {
@@ -2159,14 +2162,13 @@ function createFormControl(props = {}, flushRootRender) {
2159
2162
  ...updatedFormState,
2160
2163
  };
2161
2164
  };
2162
- if (isFunction(_options.defaultValues)) {
2165
+ const _resetDefaultValues = () => isFunction(_options.defaultValues) &&
2163
2166
  _options.defaultValues().then((values) => {
2164
2167
  reset(values, _options.resetOptions);
2165
2168
  _subjects.state.next({
2166
2169
  isLoading: false,
2167
2170
  });
2168
2171
  });
2169
- }
2170
2172
  return {
2171
2173
  control: {
2172
2174
  register,
@@ -2180,6 +2182,7 @@ function createFormControl(props = {}, flushRootRender) {
2180
2182
  _updateFieldArray,
2181
2183
  _getFieldArray,
2182
2184
  _reset,
2185
+ _resetDefaultValues,
2183
2186
  _updateFormState,
2184
2187
  _subjects,
2185
2188
  _proxyFormState,
@@ -2303,6 +2306,9 @@ function useForm(props = {}) {
2303
2306
  if (props.values && !deepEqual(props.values, control._defaultValues)) {
2304
2307
  control._reset(props.values, control._options.resetOptions);
2305
2308
  }
2309
+ else {
2310
+ control._resetDefaultValues();
2311
+ }
2306
2312
  }, [props.values, control]);
2307
2313
  React.useEffect(() => {
2308
2314
  if (!control._state.mount) {