mirror of
https://github.com/cupcakearmy/formhero.git
synced 2025-09-06 06:10:40 +00:00
examples
This commit is contained in:
35
examples/custom.tsx
Normal file
35
examples/custom.tsx
Normal 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'))
|
Reference in New Issue
Block a user