react-hook-form 7.20.1 → 7.20.2
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.js +15 -5
- 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/logic/generateWatchOutput.d.ts +2 -1
- package/dist/utils/objectHasFunction.d.ts +2 -0
- package/package.json +3 -4
package/dist/index.esm.js
CHANGED
@@ -155,7 +155,7 @@ function useFormState(props) {
|
|
155
155
|
|
156
156
|
var isString = (value) => typeof value === 'string';
|
157
157
|
|
158
|
-
|
158
|
+
var generateWatchOutput = (names, _names, formValues, isGlobal) => {
|
159
159
|
const isArray = Array.isArray(names);
|
160
160
|
if (isString(names)) {
|
161
161
|
isGlobal && _names.watch.add(names);
|
@@ -167,7 +167,18 @@ function generateWatchOutput(names, _names, formValues, isGlobal) {
|
|
167
167
|
}
|
168
168
|
isGlobal && (_names.watchAll = true);
|
169
169
|
return formValues;
|
170
|
-
}
|
170
|
+
};
|
171
|
+
|
172
|
+
var isFunction = (value) => typeof value === 'function';
|
173
|
+
|
174
|
+
var objectHasFunction = (data) => {
|
175
|
+
for (const key in data) {
|
176
|
+
if (isFunction(data[key])) {
|
177
|
+
return true;
|
178
|
+
}
|
179
|
+
}
|
180
|
+
return false;
|
181
|
+
};
|
171
182
|
|
172
183
|
function useWatch(props) {
|
173
184
|
const methods = useFormContext();
|
@@ -180,7 +191,8 @@ function useWatch(props) {
|
|
180
191
|
callback: (formState) => {
|
181
192
|
if (shouldSubscribeByName(_name.current, formState.name, exact)) {
|
182
193
|
const fieldValues = generateWatchOutput(_name.current, control._names, formState.values || control._formValues);
|
183
|
-
updateValue(isUndefined(_name.current)
|
194
|
+
updateValue(isUndefined(_name.current) ||
|
195
|
+
(isObject(fieldValues) && !objectHasFunction(fieldValues))
|
184
196
|
? Object.assign({}, fieldValues) : Array.isArray(fieldValues)
|
185
197
|
? [...fieldValues]
|
186
198
|
: fieldValues);
|
@@ -543,8 +555,6 @@ const useFieldArray = (props) => {
|
|
543
555
|
};
|
544
556
|
};
|
545
557
|
|
546
|
-
var isFunction = (value) => typeof value === 'function';
|
547
|
-
|
548
558
|
function cloneObject(data) {
|
549
559
|
let copy;
|
550
560
|
const isArray = Array.isArray(data);
|