Last active
February 14, 2019 14:51
-
-
Save highercomve/8aae5bde1fdb3cb0c49329149ecc476b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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