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

Function UseFormState

app/src/useFormState.tsx:53–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51};
52
53export const UseFormState: React.FC = () => {
54 const { register, handleSubmit, control, reset } = useForm<FormInputs>({
55 mode: 'onChange',
56 });
57 const onValid = () => {};
58
59 renderCounter++;
60
61 return (
62 <form onSubmit={handleSubmit(onValid)}>
63 <input
64 placeholder="nest.nest1"
65 {...register('nestItem.nest1', { required: true })}
66 />
67 <input
68 placeholder="arrayItem.0.test1"
69 {...register('arrayItem.0.test1', { required: true })}
70 />
71 <input
72 {...register('firstName', { required: true })}
73 placeholder="firstName"
74 />
75 <input
76 {...register('lastName', { required: true, maxLength: 5 })}
77 placeholder="lastName"
78 />
79 <input
80 type="number"
81 {...register('min', { min: 10 })}
82 placeholder="min"
83 />
84 <input
85 type="number"
86 {...register('max', { max: 20 })}
87 placeholder="max"
88 />
89 <input
90 type="date"
91 {...register('minDate', { min: '2019-08-01' })}
92 placeholder="minDate"
93 />
94 <input
95 type="date"
96 {...register('maxDate', { max: '2019-08-01' })}
97 placeholder="maxDate"
98 />
99 <input
100 {...register('minLength', { minLength: 2 })}
101 placeholder="minLength"
102 />
103 <input
104 {...register('minRequiredLength', { minLength: 2, required: true })}
105 placeholder="minRequiredLength"
106 />
107 <select {...register('selectNumber', { required: true })}>
108 <option value="">Select</option>
109 <option value={1}>1</option>
110 <option value={2}>1</option>

Callers

nothing calls this directly

Calls 4

useFormFunction · 0.85
handleSubmitFunction · 0.85
registerFunction · 0.85
resetFunction · 0.85

Tested by

no test coverage detected