This commit is contained in:
cupcakearmy
2019-09-28 17:20:56 +02:00
parent a34f11103b
commit 53d9395da9
5 changed files with 196 additions and 0 deletions

35
examples/custom.tsx Normal file
View File

@@ -0,0 +1,35 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { useForm } from '../dist'
const Index: React.FC = () => {
const { auto, form, errors } = useForm({
awesome: true,
})
return (
<form onSubmit={e => {
e.preventDefault()
console.log(form)
}}>
<h1>Custom</h1>
<label>
<input type="checkbox" {...auto('awesome', {
setter: 'checked',
getter: 'onChange',
extractor: (e) => e.target.checked
})} />
Is it awesome?
</label>
<input type="submit" />
</form>
)
}
ReactDOM.render(<Index />, document.getElementById('custom'))