Declarative React Forms
npm install react-connect-formcreateFormcreateFieldwithFormvalidatorsjsx
import { Form, Field, Submit } from "react-connect-form"const UserForm = () => (
)
`$3
`jsx
import { Form, Field, Submit } from "react-connect-form"
import regex from 'regex-email'function isEmail(value) {
if (!regex.test(value)) {
return "Please enter a valid email address"
}
}
const EmailForm = () => (
)
`$3
`jsx
import { Form, Field, Submit, validators } from "react-connect-form"
const { isEmail } = validatorsfunction isUniqueEmail(value) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (value === "robert@gmail.com") {
reject("Email is already in use")
} else {
resolve()
}
}, 1000)
})
}
const EmailForm = ({ handleSubmit }) => (
)
`$3
$3
$3
API
$3
####
####
#### $3
#### createForm
#### createField
#### withForm$3
#### validators`