react-hook-form 7.18.0 → 7.18.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.
- package/CHANGELOG.md +28 -0
- package/README.md +23 -6
- package/dist/controller.d.ts +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +13 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/types/controller.d.ts +10 -10
- package/dist/types/utils.d.ts +0 -3
- package/dist/useController.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -379,6 +379,7 @@ const useFieldArray = (props) => {
|
|
379
379
|
const [fields, setFields] = React.useState(mapIds(control._getFieldArray(name), keyName));
|
380
380
|
const _fieldIds = React.useRef(fields);
|
381
381
|
const _name = React.useRef(name);
|
382
|
+
const _actioned = React.useRef(false);
|
382
383
|
_name.current = name;
|
383
384
|
_fieldIds.current = fields;
|
384
385
|
control._names.array.add(name);
|
@@ -393,6 +394,7 @@ const useFieldArray = (props) => {
|
|
393
394
|
});
|
394
395
|
const updateValues = React.useCallback((updatedFieldArrayValuesWithKey) => {
|
395
396
|
const updatedFieldArrayValues = omitKeys(updatedFieldArrayValuesWithKey, keyName);
|
397
|
+
_actioned.current = true;
|
396
398
|
set(control._formValues, name, updatedFieldArrayValues);
|
397
399
|
setFields(updatedFieldArrayValuesWithKey);
|
398
400
|
return updatedFieldArrayValues;
|
@@ -468,15 +470,17 @@ const useFieldArray = (props) => {
|
|
468
470
|
}
|
469
471
|
}
|
470
472
|
}
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
473
|
+
if (_actioned.current) {
|
474
|
+
control._executeSchema([name]).then((result) => {
|
475
|
+
const error = get(result.errors, name);
|
476
|
+
if (error && error.type && !get(control._formState.errors, name)) {
|
477
|
+
set(control._formState.errors, name, error);
|
478
|
+
control._subjects.state.next({
|
479
|
+
errors: control._formState.errors,
|
480
|
+
});
|
481
|
+
}
|
482
|
+
});
|
483
|
+
}
|
480
484
|
control._subjects.watch.next({
|
481
485
|
name,
|
482
486
|
values: control._formValues,
|