formhero/examples/simple.tsx

30 lines
552 B
TypeScript
Raw Permalink Normal View History

2019-09-28 15:20:56 +00:00
import React from 'react'
import { useForm } from '../dist'
2023-01-31 00:26:27 +00:00
import { mount } from './common'
2019-09-28 15:20:56 +00:00
const Index: React.FC = () => {
2023-01-31 00:26:27 +00:00
const { field, form } = useForm({
2019-10-19 06:45:14 +00:00
username: 'unicorn',
password: '',
})
return (
<form
2023-01-31 00:26:27 +00:00
onSubmit={(e) => {
2019-10-19 06:45:14 +00:00
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
}
2023-01-31 00:26:27 +00:00
mount(Index)