import React, { useState } from 'react'
import ReactDOM from 'react-dom'
import { useForm, HTMLInputExtractor } from '../'
const TextError: React.FC<{ error?: string }> = ({ error }) => !error
? null
:
{error}
const Index: React.FC = () => {
const { auto, form, update, errors } = useForm({
username: '',
password: '',
type: 'formhero',
awesome: true,
}, {
username: /^test/,
password: {
validator: /^.{3,}$/,
message: 'To short',
},
awesome: (value) => !!value
}, { extractor: HTMLInputExtractor })
const _submit = (e: React.MouseEvent) => {
e.preventDefault()
console.log(form, errors)
}
return (
)
}
ReactDOM.render(, document.getElementById('root'))
// @ts-ignore
// if (module.hot) module.hot.accept()