Created
February 16, 2021 02:08
-
-
Save carmandomx/ef864d04ecd5234e7ac3f382a83b44e4 to your computer and use it in GitHub Desktop.
Sencillo ejemplo de un formulario c/ RHF
This file contains 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 { useForm } from "react-hook-form"; | |
const Login = () => { | |
const { register, handleSubmit } = useForm(); | |
const onSubmit = (data) => { | |
console.log(data); | |
}; | |
return ( | |
<form onSubmit={handleSubmit(onSubmit)}> | |
<label> | |
Email: | |
<input | |
type="email" | |
name="elchavodelocho" | |
ref={register} | |
placeholder="Email" | |
/> | |
</label> | |
<label> | |
Password: | |
<input | |
type="password" | |
placeholder="Password" | |
name="password" | |
ref={register} | |
/> | |
</label> | |
<button>Login!</button> | |
</form> | |
); | |
}; | |
export default Login; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment