Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/premieroctet/final-form-persist
🏁 Persist your final-form values into a storage
https://github.com/premieroctet/final-form-persist
Last synced: about 2 months ago
JSON representation
🏁 Persist your final-form values into a storage
- Host: GitHub
- URL: https://github.com/premieroctet/final-form-persist
- Owner: premieroctet
- Created: 2019-11-18T14:00:41.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-11T13:57:57.000Z (about 2 years ago)
- Last Synced: 2024-10-05T07:14:23.018Z (3 months ago)
- Language: TypeScript
- Homepage:
- Size: 760 KB
- Stars: 9
- Watchers: 6
- Forks: 2
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# final-form-persist
> Persist your final-form values into a storage
[![NPM](https://img.shields.io/npm/v/final-form-persist.svg)](https://www.npmjs.com/package/final-form-persist) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
## Install
```bash
npm install --save final-form-persist
```or
```bash
yarn add final-form-persist
```## Usage
```tsx
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](https://codesandbox.io/s/final-form-persist-example-s4wz5) build with [react-final-form](https://github.com/final-form/react-final-form)
## API
### `createPersistDecorator`
Creates a final form decorator.
```ts
createPersistDecorator = ({
name: string
debounceTime?: number
whitelist: string[]
storage?: Storage
}) => FinalFormPersistDecorator
```### type `FinalFormPersistDecorator`
```ts
{
persistDecorator: Decorator
clear: () => void
isPersisted: boolean
}
```## License
MIT © [premieroctet](https://github.com/premieroctet)