Skip to content

Instantly share code, notes, and snippets.

@highercomve
Last active February 14, 2019 14:51
Show Gist options
  • Select an option

  • Save highercomve/8aae5bde1fdb3cb0c49329149ecc476b to your computer and use it in GitHub Desktop.

Select an option

Save highercomve/8aae5bde1fdb3cb0c49329149ecc476b to your computer and use it in GitHub Desktop.
import React from 'react'
import useValidatedForm from 'react-valida-hook'
const initialState = {
firstName: '',
lastName: '',
email: ''
}
const validations = [
{
name: 'firstName',
type: 'required',
stateMap: 'firstName'
},
{
name: 'lastName',
type: 'required',
stateMap: 'lastName'
},
{
name: 'email',
type: 'required',
stateMap: 'email'
},
{
name: 'email',
type: 'isEmail',
stateMap: 'email'
}
]
function FormComponent (props) {
const [formData, validation, validateForm, getData, setData] = useValidatedForm(initialState, validations)
return (<span>Testing</span>)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment