Package Exports
- final-form-arrays
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (final-form-arrays) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
🏁 Final Form Arrays
Mutators for updating array fields in 🏁 Final Form.
Installation
npm install --save final-form-arraysor
yarn add final-form-arraysUsage
import { createForm } from 'final-form'
import arrayMutators from 'final-form-arrays'
// Create Form
const form = createForm({
mutators: { ...arrayMutators }
onSubmit
})
// push
form.mutators.push('customers', { firstName: '', lastName: '' })
// pop
const customer = form.mutators.pop('customers')Table of Contents
Mutators
form.mutators.insert(name: string, index:number, value: any) => undefined
Inserts a value into the specified index of the array field.
form.mutators.move(name: string, from: number, to: number) => undefined
Moves a value from one index to another index in the array field.
form.mutators.pop(name: string) => any
Pops a value off the end of an array field. Returns the value.
form.mutators.push(name: string, value: any) => void
Pushes a value onto the end of an array field.
form.mutators.remove(name: string, index: number) => any
Removes a value from the specified index of the array field. Returns the removed value.
form.mutators.shift(name: string) => any
Removes a value from the beginning of the array field. Returns the value.
form.mutators.swap(name: string, indexA: number, indexB: number) => void
Swaps the position of two values in the array field.
form.mutators.unshift(name: string, value: any) => void
Inserts a value onto the beginning of the array field.