mirror of
https://github.com/cupcakearmy/formhero.git
synced 2024-12-23 00:26:23 +00:00
Merge branch 'master' of https://github.com/CupCakeArmy/formhero
This commit is contained in:
commit
cf27d8c77f
40
README.md
40
README.md
@ -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({
|
||||||
|
Loading…
Reference in New Issue
Block a user