1.0.5 • Published 5 years ago
lomake v1.0.5
Form handling tool for react app's
import React from 'react'
import { useLomake } from 'lomake'
const initialState = {
values: { firstName: '', lastName: '' },
}
function validator(values) {
let errors = {}
if (!values.firstName) errors.firstName = 'required'
return errors
}
function handleSubmit(values) {
return new Promise(...)
}
function YourForm(props) {
const {
values,
errors,
touched,
focus,
isValidating,
isSubmitting,
eventHandlers:{
onChange,
onBlur,
onFocus
} = useLomake({ initialState, validator, handleSubmit })
return (
...
)
}