This commit is contained in:
cupcakearmy 2019-09-28 17:20:59 +02:00
commit cf27d8c77f

View File

@ -10,16 +10,54 @@
- Typescript compatible - Typescript compatible
- Customizable extractor, validator, getter and setters. (More in the docs) - Customizable extractor, validator, getter and setters. (More in the docs)
- No Deps - **0** Dependencies
- Tiny - Tiny
- React Hooks - React Hooks
###### Installation
```
npm i formhero
```
## 🚀 Quickstart ## 🚀 Quickstart
```typescript ```typescript
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import { useForm } from 'formhero' import { useForm } from 'formhero'
const Form = () => {
const { auto, form } = useForm({
username: '',
password: '',
})
const _submit = (e: React.FormEvent) => {
e.preventDefault()
console.log(form)
}
return (
<div>
<form onSubmit={_submit}>
<input {...auto('username')} />
<input {...auto('password')} />
<button type="submit">Go 🚀</button>
</form>
</div>
)
}
```
## 🔥 Avanced Example
```typescript
import ReactDOM from 'react-dom'
import { useForm } from 'formhero'
const Form = () => { const Form = () => {
const { auto, form, errors } = useForm({ const { auto, form, errors } = useForm({