项目
在 GitHub 查看
jaredpalmer/formik-persist
关于
💾 Persist and rehydrate a Formik form to localStorage
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Formik Persist
Persist and rehydrate a Formik form.
npm install formik-persist --save
Basic Usage
Just import the <Persist > component and put it inside any Formik form. It renders null!
import React from 'react'
import { Formik, Field, Form } from 'formik'
import { Persist } from 'formik-persist'
export const Signup = () =>
<div>
<h1>My Cool Persisted Form</h1>
<Formik
onSubmit={values => console.log(values)}
initialValues={{ firstName: '', lastName: '', email: '' }}
render={props =>
<Form className="whatever">
<Field name="firstName" placeholder="First Name" />
<Field name="lastName" placeholder="Last Name" />
<Field name="email" type="email" placeholder="Email Address" />
<button type="submit">Submit</button>
<Persist name="signup-form" />
</Form>}
/>
</div>;
Props
Only three props!
name: string: LocalStorage key to save form state todebounce:? number: Default is300. Number of ms to debounce the function that saves form state.isSessionStorage:? boolean: default isfalse. Send if you want Session storage inplace of Local storage
Author
- Jared Palmer @jaredpalmer
Todo
- Alternative storages (localForage)
- Support AsyncStorage for React Native
探索相关项目
加载中…