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

Function remove

src/useFieldArray.ts:207–219  ·  view source on GitHub ↗
(index?: number | number[])

Source from the content-addressed store, hash-verified

205 };
206
207 const remove = (index?: number | number[]) => {
208 const updatedFieldArrayValues: Partial<
209 FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>
210 >[] = removeArrayAt(control._getFieldArray(name), index);
211 ids.current = removeArrayAt(ids.current, index);
212 updateValues(updatedFieldArrayValues);
213 setFields(updatedFieldArrayValues);
214 !Array.isArray(get(control._fields, name)) &&
215 set(control._fields, name, undefined);
216 control._setFieldArray(name, updatedFieldArrayValues, removeArrayAt, {
217 argA: index,
218 });
219 };
220
221 const insert = (
222 index: number,

Callers 15

ItemFunction · 0.85
AppFunction · 0.85
ComponentFunction · 0.85
ComponentFunction · 0.85
ComponentFunction · 0.85
AppFunction · 0.85
ArrayFieldFunction · 0.85
FieldArrayFunction · 0.85
remove.test.tsFile · 0.85
ComponentFunction · 0.85
NestedFunction · 0.85
AppFunction · 0.85

Calls

no outgoing calls

Tested by 13

ItemFunction · 0.68
AppFunction · 0.68
ComponentFunction · 0.68
ComponentFunction · 0.68
ComponentFunction · 0.68
AppFunction · 0.68
ArrayFieldFunction · 0.68
FieldArrayFunction · 0.68
ComponentFunction · 0.68
NestedFunction · 0.68
AppFunction · 0.68
ComponentFunction · 0.68