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

https://github.com/telenko/react-form


https://github.com/telenko/react-form

Last synced: 10 days ago
JSON representation

Awesome Lists containing this project

README

          

# react-form

Simple set of hooks to organize form validation (analog to formik's useFormik)

# why?

Much more simple and efficient tiny package

# plans

Work in progress, current version is beta
docs ..tbd

# example

```tsx
type PersonForm = { name: string; age: number };

const SomeForm: React.FC = () => {
const yupValidator = useMemo(() => {
yup.object().shape({
name: yup.string().required(),
age: yup.string().optional(),
});
}, []);
const [validator] = useYupSyncValidator(yupValidator);
const form = useForm(
{ // default values
name: "",
age: 0,
},
validator, // validator instance
(person) => {
// on submit
save(person);
}
);
return (





);
};
```