import React from "react"; import ReactDOM from "react-dom"; import useForm from "react-hook-form"; import "./styles.css"; function App() { const { register, handleSubmit, errors } = useForm(); const onSubmit = data => { alert(JSON.stringify(data)); }; const intialValues = { firstName: "bill", lastName: "luo", email: "bluebill1049@hotmail.com", age: -1 }; return (
value !== "bill" })} />
{errors.firstName &&

Your name is not bill

}
value.length > 3 })} />
{errors.lastName &&

Your last name is less than 3 characters

}
parseFloat(value) > 0, lessThanHundred: value => parseFloat(value) < 200 } })} />
{errors.age && errors.age.type === "positiveNumber" && (

Your age is invalid

)} {errors.age && errors.age.type === "lessThanHundred" && (

Your age should be greater than 200

)}
); } const rootElement = document.getElementById("root"); ReactDOM.render(, rootElement);