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

Function App

examples/V6/customMaskedInputWithController.tsx:42–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40};
41
42export default function App() {
43 const { handleSubmit, errors, control } = useForm({
44 reValidateMode: 'onSubmit',
45 });
46 const [tel, setTel] = React.useState('7');
47 return (
48 <div className="App">
49 <h1>Hello CodeSandbox</h1>
50 <form onSubmit={handleSubmit(onSubmit)}>
51 <div>
52 <Controller
53 as={<CustomMaskedInput />}
54 value={tel}
55 onChange={([e]) => {
56 setTel(e);
57 return { value: e };
58 }}
59 rules={{
60 validate: {
61 inputTelRequired: isNotFilledTel,
62 },
63 }}
64 defaultValue={tel}
65 name="ControlledMaskedInput"
66 control={control}
67 />
68
69 {errors.ControlledMaskedInput && (
70 <p>{errors.ControlledMaskedInput.message}</p>
71 )}
72 </div>
73 <input type="submit" />
74 </form>
75 </div>
76 );
77}

Callers

nothing calls this directly

Calls 2

useFormFunction · 0.85
handleSubmitFunction · 0.85

Tested by

no test coverage detected