mirror of
https://github.com/cupcakearmy/formhero.git
synced 2024-12-23 00:26:23 +00:00
38 lines
703 B
TypeScript
38 lines
703 B
TypeScript
import React from 'react'
|
|
import ReactDOM from 'react-dom'
|
|
|
|
import { useForm } from '../dist'
|
|
|
|
const Index: React.FC = () => {
|
|
const { field, form, errors } = useForm({
|
|
awesome: true,
|
|
})
|
|
|
|
return (
|
|
<form
|
|
onSubmit={e => {
|
|
e.preventDefault()
|
|
console.log(form)
|
|
}}
|
|
>
|
|
<h1>Custom</h1>
|
|
|
|
<label>
|
|
<input
|
|
type="checkbox"
|
|
{...field('awesome', {
|
|
setter: 'checked',
|
|
getter: 'onChange',
|
|
extractor: e => e.target.checked,
|
|
})}
|
|
/>
|
|
Is it awesome?
|
|
</label>
|
|
|
|
<input type="submit" />
|
|
</form>
|
|
)
|
|
}
|
|
|
|
ReactDOM.render(<Index />, document.getElementById('custom'))
|