https://github.com/tylershin/formik-persist-state
https://github.com/tylershin/formik-persist-state
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tylershin/formik-persist-state
- Owner: TylerShin
- Created: 2022-05-02T05:32:54.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-02T12:33:22.000Z (about 4 years ago)
- Last Synced: 2025-03-08T18:46:33.898Z (over 1 year ago)
- Language: TypeScript
- Size: 45.9 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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