MCPcopy Create free account
hub / github.com/react-hook-form/react-hook-form / App

Function App

examples/V6/basic.tsx:5–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { useForm } from 'react-hook-form';
4
5export default function App() {
6 const { register, handleSubmit } = useForm();
7 const onSubmit = (data) => {
8 alert(JSON.stringify(data));
9 };
10
11 return (
12 <div className="App">
13 <form onSubmit={handleSubmit(onSubmit)}>
14 <div>
15 <label htmlFor="firstName">First Name</label>
16 <input name="firstName" placeholder="bill" ref={register} />
17 </div>
18
19 <div>
20 <label htmlFor="lastName">Last Name</label>
21 <input name="lastName" placeholder="luo" ref={register} />
22 </div>
23
24 <div>
25 <label htmlFor="email">Email</label>
26 <input
27 name="email"
28 placeholder="bluebill1049@hotmail.com"
29 type="email"
30 ref={register}
31 />
32 </div>
33 <button type="submit">Submit</button>
34 </form>
35 </div>
36 );
37}

Callers

nothing calls this directly

Calls 2

useFormFunction · 0.85
handleSubmitFunction · 0.85

Tested by

no test coverage detected