type SwapFieldValuesFn<TFormData> = <TFieldName>(arrayFieldName, indexA, indexB, options?) => void;Defined in: FormApi/FormApiArrayMethods.types.public.ts:97
Swaps two elements in an array field.
Passing equal indices does nothing. Invalid indices or a runtime value that is not an array produce a warning and leave the value unchanged.
By default, the update marks the array field as touched and dirty, notifies change listeners, and runs change validation.
TFormData
Library-managed. Do not specify explicitly.
TFieldName extends ArrayFieldName<TFormData>
Library-managed. Do not specify explicitly.
TFieldName
The array field path.
number
The first index to swap, from 0 through array.length - 1.
number
The second index to swap, from 0 through array.length - 1.
Controls metadata updates and whether validation runs.
void
// items: ['first', 'second', 'third']
formApi.swapFieldValues('items', 0, 2)
// items: ['third', 'second', 'first']