react-hook-form 7.55.0-next.3 → 7.55.0-next.4
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/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +8 -7
- package/dist/index.esm.mjs.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/react-server.esm.mjs +5 -5
- package/dist/react-server.esm.mjs.map +1 -1
- package/dist/useWatch.d.ts.map +1 -1
- package/package.json +12 -12
package/dist/index.esm.mjs
CHANGED
@@ -314,6 +314,7 @@ function useWatch(props) {
|
|
314
314
|
const methods = useFormContext();
|
315
315
|
const { control = methods.control, name, defaultValue, disabled, exact, } = props || {};
|
316
316
|
const _name = React.useRef(name);
|
317
|
+
const _defaultValue = React.useRef(defaultValue);
|
317
318
|
_name.current = name;
|
318
319
|
React.useEffect(() => control._subscribe({
|
319
320
|
name: _name.current,
|
@@ -322,8 +323,8 @@ function useWatch(props) {
|
|
322
323
|
},
|
323
324
|
exact,
|
324
325
|
callback: (formState) => !disabled &&
|
325
|
-
updateValue(generateWatchOutput(_name.current, control._names, formState.values || control._formValues, false,
|
326
|
-
}), [control,
|
326
|
+
updateValue(generateWatchOutput(_name.current, control._names, formState.values || control._formValues, false, _defaultValue.current)),
|
327
|
+
}), [control, disabled, exact]);
|
327
328
|
const [value, updateValue] = React.useState(control._getWatch(name, defaultValue));
|
328
329
|
React.useEffect(() => control._removeUnmounted());
|
329
330
|
return value;
|
@@ -1994,11 +1995,6 @@ function createFormControl(props = {}) {
|
|
1994
1995
|
e.persist && e.persist();
|
1995
1996
|
}
|
1996
1997
|
let fieldValues = cloneObject(_formValues);
|
1997
|
-
if (_names.disabled.size) {
|
1998
|
-
for (const name of _names.disabled) {
|
1999
|
-
set(fieldValues, name, undefined);
|
2000
|
-
}
|
2001
|
-
}
|
2002
1998
|
_subjects.state.next({
|
2003
1999
|
isSubmitting: true,
|
2004
2000
|
});
|
@@ -2010,6 +2006,11 @@ function createFormControl(props = {}) {
|
|
2010
2006
|
else {
|
2011
2007
|
await executeBuiltInValidation(_fields);
|
2012
2008
|
}
|
2009
|
+
if (_names.disabled.size) {
|
2010
|
+
for (const name of _names.disabled) {
|
2011
|
+
set(fieldValues, name, undefined);
|
2012
|
+
}
|
2013
|
+
}
|
2013
2014
|
unset(_formState.errors, 'root');
|
2014
2015
|
if (isEmptyObject(_formState.errors)) {
|
2015
2016
|
_subjects.state.next({
|