keep-react-hook-form
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

A lib to store react-hook-form values in session storage.

type FormData = {
	username: string;
	email: string;
}

function App() {
	const { register, watch, setValue } = useForm<FormData>({ defaultValues: { email: '', username: '' } });
	
	usePersistForm<FormData>({
		formName: "login",
		watch,
		setValue,
		shouldValidate: true,
		shouldDirty: true,
		onRestored: (values) => {
			console.log(values)
		}
	})
	
	return (
		<div className="App">
			<input {...register('username')} />
			<input {...register('email')} />
		</div>
	);
}

Readme

Keywords

none

Package Sidebar

Install

npm i keep-react-hook-form

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

5.07 kB

Total Files

6

Last publish

Collaborators

  • itschip