The FieldArray Component

Learn how to use the FieldArray component to do common array manipulations on a form's state.

Sometimes, we might want to collect a value multiple times, but prior to collecting the values we don’t know the exact number of times we want to collect them. For example, if we ask our users to enter the names of their friends, we may not know how many friends they have, so we want to give them the flexibility to add and remove as many friends as they would like. We’ll save all the values in a single array. This requires us to do a lot of array manipulation that can quickly get complex. Formik provides a component that helps us easily manipulate arrays—the FieldArray component.

Get hands-on with 1200+ tech skills courses.