import React from 'react'; import { useForm } from 'react-hook-form'; import * as yup from 'yup'; // you will have to install yup import { yupResolver } from '@hookform/resolvers/yup'; // you will have to install @hookform/resolvers const SignupSchema = yup.object().shape({ firstName: yup.string().required(), age: yup.number().required().positive().integer(), website: yup.string().url(), }); export default function App() { const { register, handleSubmit, formState: { errors }, } = useForm({ resolver: yupResolver(SignupSchema), }); const onSubmit = (data) => { alert(JSON.stringify(data)); }; return (
); }