Skip to content

Instantly share code, notes, and snippets.

@carmandomx
Created February 16, 2021 02:08
Show Gist options
  • Save carmandomx/ef864d04ecd5234e7ac3f382a83b44e4 to your computer and use it in GitHub Desktop.
Save carmandomx/ef864d04ecd5234e7ac3f382a83b44e4 to your computer and use it in GitHub Desktop.
Sencillo ejemplo de un formulario c/ RHF
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