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

Function App

examples/V6/triggerFieldValidation.tsx:4–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import { useForm } from 'react-hook-form';
3
4export default function App() {
5 const { register, errors, trigger } = useForm();
6
7 console.log('errors', errors);
8
9 return (
10 <div className="App">
11 <h1>validationField</h1>
12 <label>First name: </label>
13 <input name="firstName" ref={register({ required: true })} />
14
15 <label>Last name: </label>
16 <input name="lastName" ref={register({ required: true })} />
17
18 <button
19 type="button"
20 onClick={async () => {
21 const result = await trigger(['firstName', 'lastName']);
22 if (result) {
23 console.log('Valid input');
24 }
25 }}
26 >
27 Trigger
28 </button>
29 </div>
30 );
31}

Callers

nothing calls this directly

Calls 3

useFormFunction · 0.85
registerFunction · 0.85
triggerFunction · 0.85

Tested by

no test coverage detected