MCPcopy Create free account
hub / github.com/react-hook-form/react-hook-form / setValues

Function setValues

src/logic/createFormControl.ts:763–787  ·  view source on GitHub ↗
(
    name: T,
    value: K,
    options: U,
  )

Source from the content-addressed store, hash-verified

761 };
762
763 const setValues = <
764 T extends InternalFieldName,
765 K extends SetFieldValue<TFieldValues>,
766 U extends SetValueConfig,
767 >(
768 name: T,
769 value: K,
770 options: U,
771 ) => {
772 for (const fieldKey in value) {
773 if (!value.hasOwnProperty(fieldKey)) {
774 return;
775 }
776 const fieldValue = value[fieldKey];
777 const fieldName = name + '.' + fieldKey;
778 const field = get(_fields, fieldName);
779
780 (_names.array.has(name) ||
781 isObject(fieldValue) ||
782 (field && !field._f)) &&
783 !isDateObject(fieldValue)
784 ? setValues(fieldName, fieldValue, options)
785 : setFieldValue(fieldName, fieldValue, options);
786 }
787 };
788
789 const setValue: UseFormSetValue<TFieldValues> = (
790 name,

Callers 4

setValueFunction · 0.85
FormFunction · 0.85
LoaderFunction · 0.85
AppFunction · 0.85

Calls 1

setFieldValueFunction · 0.85

Tested by 3

FormFunction · 0.68
LoaderFunction · 0.68
AppFunction · 0.68