An open API service indexing awesome lists of open source software.

https://github.com/tylershin/formik-persist-state


https://github.com/tylershin/formik-persist-state

Last synced: 5 months ago
JSON representation

Awesome Lists containing this project

README

          

# Formik Persist State

Persist and rehydrate a [Formik](https://github.com/jaredpalmer/formik) form.

```
npm install formik-persist-state --save
```

# Support

Formik >= 2 required

# Basic Usage

Just import the `` component and put it inside any Formik form. It renders `null`.

if you want to see more examples, see `src/example` folder

```js
import React from "react";
import { Formik, Field, Form } from "formik";
import { Persist } from "formik-persist-state";

export const SignUp = () => (


My Cool Persisted Form


console.log(values)}
initialValues={{ firstName: "", lastName: "", email: "" }}
render={(props) => (




Submit


)}
/>

);
```

### Props

- `cacheKey: string`: LocalStorage key to save form state to.
- `confirmMessage?: string`: confirm message when user trying to hydrate form state.
- `debounceTiming?: number`: Default is `300`. Number of ms to debounce the function that saves form state.
- `sessionStorage?: boolean`: default is `false` . Send if you want Session storage inplace of Local storage.

## Author

- Tyler Shin [@tyler__shin](https://twitter.com/tyler__shin)

## Todo

- Alternative storages