https://github.com/telenko/react-form
https://github.com/telenko/react-form
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/telenko/react-form
- Owner: telenko
- License: mit
- Created: 2021-02-23T09:14:33.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-12T13:04:05.000Z (about 5 years ago)
- Last Synced: 2024-04-26T18:22:51.368Z (about 2 years ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 (
);
};
```