@usereact/use-yup
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

useYup

react hook for yup validations

NPM

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)

Dependents (1)

Package Sidebar

Install

npm i @usereact/use-yup

Weekly Downloads

1,036

Version

1.0.0

License

MIT

Unpacked Size

5.55 kB

Total Files

5

Last publish

Collaborators

  • gurschitz
  • juhwon