Skip to content

Instantly share code, notes, and snippets.

@rizkiramadhanx
Created December 4, 2022 14:41
Show Gist options
  • Save rizkiramadhanx/e0c7590e17d2875f6fb7ec67da74eb0d to your computer and use it in GitHub Desktop.
Save rizkiramadhanx/e0c7590e17d2875f6fb7ec67da74eb0d to your computer and use it in GitHub Desktop.
import { useForm } from "react-hook-form";
const DefaultValue = () => {
const { register, handleSubmit } = useForm({
defaultValues: {
firstName: "oji",
lastName: "ramadhan"
}
});
const onSubmit = (data) => console.log(data);
return (
<form onSubmit={handleSubmit(onSubmit)}>
<label>firstName :</label>
<input {...register("firstName")} />
<label>lastName :</label>
<input {...register("lastName")} />
<button type="submit" className="submitbtn">
submit
</button>
</form>
);
};
export default DefaultValue;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment