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

Function append

src/useFieldArray.ts:163–185  ·  view source on GitHub ↗
(
    value:
      | Partial<FieldArray<TFieldValues, TFieldArrayName>>
      | Partial<FieldArray<TFieldValues, TFieldArrayName>>[],
    options?: FieldArrayMethodProps,
  )

Source from the content-addressed store, hash-verified

161 );
162
163 const append = (
164 value:
165 | Partial<FieldArray<TFieldValues, TFieldArrayName>>
166 | Partial<FieldArray<TFieldValues, TFieldArrayName>>[],
167 options?: FieldArrayMethodProps,
168 ) => {
169 const appendValue = convertToArrayPayload(cloneObject(value));
170 const updatedFieldArrayValues = appendAt(
171 control._getFieldArray(name),
172 appendValue,
173 );
174 control._names.focus = getFocusFieldName(
175 name,
176 updatedFieldArrayValues.length - 1,
177 options,
178 );
179 ids.current = appendAt(ids.current, appendValue.map(generateId));
180 updateValues(updatedFieldArrayValues);
181 setFields(updatedFieldArrayValues);
182 control._setFieldArray(name, updatedFieldArrayValues, appendAt, {
183 argA: fillEmptyArray(value),
184 });
185 };
186
187 const prepend = (
188 value:

Callers 15

FieldArrayFunction · 0.85
AppFunction · 0.85
ComponentFunction · 0.85
FormFunction · 0.85
ComponentFunction · 0.85
NestedFunction · 0.85
AppFunction · 0.85
ArrayFieldFunction · 0.85
ChildComponentFunction · 0.85
TestFunction · 0.85
ChildFunction · 0.85
FieldArrayFunction · 0.85

Calls 1

cloneObjectFunction · 0.85

Tested by 15

FieldArrayFunction · 0.68
AppFunction · 0.68
ComponentFunction · 0.68
FormFunction · 0.68
ComponentFunction · 0.68
NestedFunction · 0.68
AppFunction · 0.68
ArrayFieldFunction · 0.68
ChildComponentFunction · 0.68
TestFunction · 0.68
ChildFunction · 0.68
FieldArrayFunction · 0.68