Last active
March 3, 2021 14:58
-
-
Save apoorvmote/f5289acb86465b65abb5e100ee892ad8 to your computer and use it in GitHub Desktop.
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
... | |
<input autoComplete="off" type="text" name="title" id="todoTitle" ref={register} /> | |
... | |
<select name="category" id="category" ref={register} /> | |
... | |
<input type="radio" name="priority" id="low" value='low' className='mr-2' defaultChecked ref={register} /> | |
... | |
<input type="radio" name="priority" id="med" value='med' className='mr-2' ref={register} /> | |
... | |
<input type="radio" name="priority" id="high" value='high' className='mr-2' ref={register} /> |
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
<form className='grid gap-4 grid-col-1' onSubmit={handleSubmit(onSubmit)}> |
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 { register, handleSubmit } = useForm<TodoInput>() |
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
interface TodoInput { | |
title: string | |
priority: string | |
category: string | |
} |
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
async function onSubmit(input: TodoInput) { | |
console.log(input) | |
} |
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
const { register, handleSubmit } = useForm<TodoInput>({ | |
defaultValues: { | |
title: 'get bread', | |
category: 'grocery', | |
priority: 'med' | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment