Quick start
React Next Form is a lightweight React library for form state management. It eliminates a lot of boilerplate code, and less code means fewer bugs and things to worry about.
Installation
React Next Form relies on immer for immutable updates and yup for schema validation.
- Yarn
- NPM
yarn add -E react-next-form immer yup
Basic form
- Javascript
- Typescript
import React from "react";
import { useForm } from "react-next-form";
export default function BasicForm() {
const form = useForm({
initialValues: { name: "" },
onSubmit: values => alert(values.name);
});
return (
<div>
<input placeholder="type your name" {...form.fieldProps("name")} />
<button onClick={form.submit}>Submit</button>
</div>
);
}