formhero/examples/simple.tsx

30 lines
607 B
TypeScript
Raw Normal View History

2019-09-28 15:20:56 +00:00
import React from 'react'
import ReactDOM from 'react-dom'
import { useForm } from '../dist'
const Index: React.FC = () => {
2019-10-19 06:45:14 +00:00
const { field, form, errors } = useForm({
username: 'unicorn',
password: '',
})
return (
<form
onSubmit={e => {
e.preventDefault()
console.log(form)
}}
>
<h1>Simple</h1>
<input {...field('username')} placeholder="Username" />
<input {...field('password')} placeholder="Password" type="password" />
<input type="submit" />
</form>
)
2019-09-28 15:20:56 +00:00
}
2019-10-19 06:45:14 +00:00
ReactDOM.render(<Index />, document.getElementById('simple'))