MCPcopy Index your code
hub / github.com/react-hook-form/react-hook-form / update

Function update

src/useFieldArray.ts:314–346  ·  view source on GitHub ↗
(
    index: number,
    value: FieldArray<TFieldValues, TFieldArrayName>,
  )

Source from the content-addressed store, hash-verified

312 };
313
314 const update = (
315 index: number,
316 value: FieldArray<TFieldValues, TFieldArrayName>,
317 ) => {
318 if (disabled) {
319 return;
320 }
321
322 const updateValue = cloneObject(value);
323 const updatedFieldArrayValues = updateAt(
324 control._getFieldArray<
325 FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>
326 >(name),
327 index,
328 updateValue as FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>,
329 );
330 ids.current = [...updatedFieldArrayValues].map((item, i) =>
331 !item || i === index ? generateId() : ids.current[i],
332 );
333 updateValues(updatedFieldArrayValues);
334 setFields([...updatedFieldArrayValues]);
335 control._setFieldArray(
336 name,
337 updatedFieldArrayValues,
338 updateAt,
339 {
340 argA: index,
341 argB: updateValue,
342 },
343 true,
344 false,
345 );
346 };
347
348 const replace = (
349 value:

Callers 13

update.test.tsFile · 0.85
ComponentFunction · 0.85
AppFunction · 0.85
AppFunction · 0.85
SetValueAsyncStrictModeFunction · 0.85
WatchUseFieldArrayFunction · 0.85
NestedArrayFunction · 0.85
UseFieldArrayFunction · 0.85
NestedArrayFunction · 0.85
NestedArrayFunction · 0.85

Calls 1

cloneObjectFunction · 0.85

Tested by 3

ComponentFunction · 0.68
AppFunction · 0.68
AppFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…