MCPcopy
hub / github.com/react-component/form / getNestedField

Method getNestedField

src/createFieldsStore.js:204–223  ·  view source on GitHub ↗
(name, getter)

Source from the content-addressed store, hash-verified

202 }
203
204 getNestedField(name, getter) {
205 const fullNames = this.getValidFieldsFullName(name);
206 if (
207 fullNames.length === 0 || // Not registered
208 (fullNames.length === 1 && fullNames[0] === name) // Name already is full name.
209 ) {
210 return getter(name);
211 }
212 const isArrayValue = fullNames[0][name.length] === '[';
213 const suffixNameStartIndex = isArrayValue ? name.length : name.length + 1;
214 return fullNames
215 .reduce(
216 (acc, fullName) => set(
217 acc,
218 fullName.slice(suffixNameStartIndex),
219 getter(fullName)
220 ),
221 isArrayValue ? [] : {}
222 );
223 }
224
225 getFieldsValue = (names) => {
226 return this.getNestedFields(names, this.getFieldValue);

Callers 1

FieldsStoreClass · 0.95

Calls 1

Tested by

no test coverage detected