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

Function getValues

src/logic/createFormControl.ts:1065–1087  ·  view source on GitHub ↗
(
    fieldNames?:
      | FieldPath<TFieldValues>
      | ReadonlyArray<FieldPath<TFieldValues>>,
    config?: GetValuesConfig,
  )

Source from the content-addressed store, hash-verified

1063 };
1064
1065 const getValues: UseFormGetValues<TFieldValues> = (
1066 fieldNames?:
1067 | FieldPath<TFieldValues>
1068 | ReadonlyArray<FieldPath<TFieldValues>>,
1069 config?: GetValuesConfig,
1070 ) => {
1071 let values = {
1072 ...(_state.mount ? _formValues : _defaultValues),
1073 };
1074
1075 if (config) {
1076 values = extractFormValues(
1077 config.dirtyFields ? _formState.dirtyFields : _formState.touchedFields,
1078 values,
1079 );
1080 }
1081
1082 return isUndefined(fieldNames)
1083 ? values
1084 : isString(fieldNames)
1085 ? get(values, fieldNames)
1086 : fieldNames.map((name) => get(values, name));
1087 };
1088
1089 const getFieldState: UseFormGetFieldState<TFieldValues> = (
1090 name,

Callers 15

_getDirtyFunction · 0.85
FormFunction · 0.85
TestFunction · 0.85
AppFunction · 0.85
ComponentFunction · 0.85
handleAddInnerFunction · 0.85
FormFunction · 0.85
AppFunction · 0.85
move.test.tsxFile · 0.85
AppFunction · 0.85
ComponentFunction · 0.85

Calls 1

extractFormValuesFunction · 0.85

Tested by 14

FormFunction · 0.68
TestFunction · 0.68
AppFunction · 0.68
ComponentFunction · 0.68
handleAddInnerFunction · 0.68
FormFunction · 0.68
AppFunction · 0.68
AppFunction · 0.68
ComponentFunction · 0.68
FormFunction · 0.68
AppFunction · 0.68
AppFunction · 0.68