Download react-hook-form/examples/V6/basic.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 961 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/examples/V6/basic.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/examples/V6/basic.tsx
-
curl -L -o basic.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-hook-form/examples/V6/basic.tsx
961 Bytes
| import React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import { useForm } from 'react-hook-form'; | |
| export default function App() { | |
| const { register, handleSubmit } = useForm(); | |
| const onSubmit = (data) => { | |
| alert(JSON.stringify(data)); | |
| }; | |
| return ( | |
| <div className="App"> | |
| <form onSubmit={handleSubmit(onSubmit)}> | |
| <div> | |
| <label htmlFor="firstName">First Name</label> | |
| <input name="firstName" placeholder="bill" ref={register} /> | |
| </div> | |
| <div> | |
| <label htmlFor="lastName">Last Name</label> | |
| <input name="lastName" placeholder="luo" ref={register} /> | |
| </div> | |
| <div> | |
| <label htmlFor="email">Email</label> | |
| <input | |
| name="email" | |
| placeholder="bluebill1049@hotmail.com" | |
| type="email" | |
| ref={register} | |
| /> | |
| </div> | |
| <button type="submit">Submit</button> | |
| </form> | |
| </div> | |
| ); | |
| } | |