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

Function DelayError

app/src/delayError.tsx:4–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2import React from 'react';
3
4export function DelayError() {
5 const {
6 register,
7 reset,
8 formState: { errors },
9 } = useForm({
10 delayError: 100,
11 mode: 'onChange',
12 defaultValues: {
13 first: '',
14 last: '',
15 },
16 });
17 return (
18 <form>
19 <input
20 {...register('first', {
21 maxLength: {
22 value: 1,
23 message: 'First too long.',
24 },
25 })}
26 placeholder="First field"
27 />
28 {errors.first?.message && <p>{errors.first?.message}</p>}
29 <input
30 autoComplete="off"
31 {...register('last', {
32 maxLength: {
33 value: 5,
34 message: 'Last too long.',
35 },
36 minLength: {
37 value: 2,
38 message: 'Last too long.',
39 },
40 })}
41 placeholder="Last field"
42 />
43 {errors.last?.message && <p>{errors.last?.message}</p>}
44 <button
45 type={'button'}
46 onClick={() =>
47 reset({
48 first: '',
49 last: '',
50 })
51 }
52 >
53 reset
54 </button>
55 </form>
56 );
57}

Callers

nothing calls this directly

Calls 3

useFormFunction · 0.85
registerFunction · 0.85
resetFunction · 0.85

Tested by

no test coverage detected