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.concat(name: string, value: Array<any>) => voidform.mutators.insert(name: string, index: number, value: any) => undefinedform.mutators.move(name: string, from: number, to: number) => undefinedform.mutators.pop(name: string) => anyform.mutators.push(name: string, value: any) => voidform.mutators.remove(name: string, index: number) => anyform.mutators.removeBatch(name: string, indexes: Array<number>) => undefinedform.mutators.shift(name: string) => anyform.mutators.swap(name: string, indexA: number, indexB: number) => voidform.mutators.update(name: string, index: number, value: any) => voidform.mutators.unshift(name: string, value: any) => void
Mutators
form.mutators.concat(name: string, value: Array<any>) => void
Concatenates an array at the end of the array field.
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.removeBatch(name: string, indexes: Array<number>) => undefined
Removes the values at the specified indexes of the array field.
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.update(name: string, index: number, value: any) => void
Updates a value of the specified index of the array field.
form.mutators.unshift(name: string, value: any) => void
Inserts a value onto the beginning of the array field.