1.0.4 • Published 4 years ago

final-form-persist v1.0.4

Weekly downloads
2,179
License
MIT
Repository
github
Last release
4 years ago

final-form-persist

Persist your final-form values into a storage

NPM JavaScript Style Guide

Install

npm install --save final-form-persist

or

yarn add final-form-persist

Usage

import { createForm } from 'final-form'
import { createPersistDecorator } from 'final-form-persist'

const form = createForm({ onSubmit })

const { persistDecorator, clear } = createPersistDecorator({
  name: 'myPersistKey'
  debounceTime: 500 // in ms
  whitelist: ['some', 'key']
  storage: localStorage // this is the default
})

const undecorate = persistDecorator(form)

// Use form

// Remove the entry from the storage if you want
clear()

// Clean up
undecorate()

Example

Example build with react-final-form

API

createPersistDecorator

Creates a final form decorator.

createPersistDecorator = ({
  name: string
  debounceTime?: number
  whitelist: string[]
  storage?: Storage
}) => FinalFormPersistDecorator

type FinalFormPersistDecorator

{
  persistDecorator: Decorator
  clear: () => void
  isPersisted: boolean
}

License

MIT © premieroctet

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago