useFieldArray
Hook to easily manage a single field whose value is an array.
Type#
UseFieldArrayOptions#
Configuration to pass to useFieldArray()
form#
The form instance this field should be bound to. If not specified, it will be used the form instance available in FormContext.
UseFieldArrayResult#
It is returned by useFieldArray() and represents the field instance that gives access to props and methods to easily manage the field.
name#
The name of the field.
value#
The array value of the field.
names#
The array of field names (with dot notation) of the items contained in the array value of this field value. For example, if the form values are:
then using useFieldArray("colors") you would get:
form#
The Form instance this field is bound to.
setValue#
Sets the array value of the field.
push#
Adds items at the end of the array value of the field.
pop#
Pops the last item from the array value of the field.
unshift#
Adds items at the beginning of the array value of the field.
insertAt#
Inserts an item at specific index into the array value of the field.
removeAt#
Removes an item at specific index from the array value of the field.
remove#
Removes an item from the array value of the field.
clear#
Sets the array value of the field to [].