MCPcopy
hub / github.com/react-hook-form/react-hook-form / getFieldValue

Function getFieldValue

src/logic/getFieldValue.ts:12–32  ·  view source on GitHub ↗
(_f: Field['_f'])

Source from the content-addressed store, hash-verified

10import getRadioValue from './getRadioValue';
11
12export default function getFieldValue(_f: Field['_f']) {
13 const ref = _f.ref;
14
15 if (isFileInput(ref)) {
16 return ref.files;
17 }
18
19 if (isRadioInput(ref)) {
20 return getRadioValue(_f.refs).value;
21 }
22
23 if (isMultipleSelect(ref)) {
24 return [...ref.selectedOptions].map(({ value }) => value);
25 }
26
27 if (isCheckBox(ref)) {
28 return getCheckboxValue(_f.refs).value;
29 }
30
31 return getFieldValueAs(isUndefined(ref.value) ? _f.ref.value : ref.value, _f);
32}

Callers 3

updateValidAndValueFunction · 0.85
onChangeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…