useFieldArray
Hook to easily manage a single field whose value is an array.
#
Type#
UseFieldArrayOptionsConfiguration to pass to useFieldArray()
#
formThe form instance this field should be bound to. If not specified, it will be used the form instance available in FormContext.
#
UseFieldArrayResultIt is returned by useFieldArray()
and represents the field instance that gives access to props and methods to easily manage the field.
#
nameThe name of the field.
#
valueThe array value of the field.
#
namesThe 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:
#
formThe Form instance this field is bound to.
#
setValueSets the array value of the field.
#
pushAdds items at the end of the array value of the field.
#
popPops the last item from the array value of the field.
#
unshiftAdds items at the beginning of the array value of the field.
#
insertAtInserts an item at specific index into the array value of the field.
#
removeAtRemoves an item at specific index from the array value of the field.
#
removeRemoves an item from the array value of the field.
#
clearSets the array value of the field to []
.