@usereact/use-yup
v1.0.0
Published
react hook for yup validations
Downloads
80
Readme
useYup
react hook for yup validations
Install
npm install --save @usereact/use-yup
Usage
``tsx import React, { useState } from 'react' import useYup from '@usereact/use-yup'
const validationSchema = yup.object().shape({ name: yup.string().required(), email: yup.string().required(), })
function Example() { const [values, setValues] = useState({ name: '', email: '', })
const { errors, validate } = useYup(values, validationSchema, { validateOnChange: true }) console.log('errors: ', errors)
const handleChange = e => { const { name, value } = e.currentTarget setValues(prevState => ({ ...prevState, [name]: value })) }
return ( ) }
## License
MIT © [JuHwon](https://github.com/JuHwon)