This hook supplies you with functions for manipulating the array/list of fields, it's fast! See the Arrays and Lists to learn more.
The name of the field. We must provide it when using this hook.
object with the following options:
The corresponding ID of the
useForm hook. We only need it when using multiple form hooks at the same time.
The default value of the field. Useful for dealing with the case of conditional fields.
(value: any, values: FormValues) => any | Promise<any>
A synchronous/asynchronous function that is used for the field-level validation.
An array that holds field names (e.g.
foo), which can be used for the
name attributes of a field.
- It refers to the location of the field in the form state. If the referenced value isn't an
arraytype, returns an empty array instead.
- It doesn't include the field data. If you need to access the data, use the use or getState methods.
object with the following methods:
(value: FieldValue, options?: Object) => void
Add a value to the end of an array.
(index: number, value: FieldValue, options?: Object) => void
Insert an element at a given index into the array.
(indexA: number, indexB: number) => void
Swap two values in an array.
(from: number, to: number) => void
Move an element in an array to another index.
(index: number) => FieldValue
Remove an element at an index of an array and return it.
The example demonstrates the basic usage of this hook.