({ control }: { control: Control<FormInputs> })
| 23 | }; |
| 24 | |
| 25 | const SubForm = ({ control }: { control: Control<FormInputs> }) => { |
| 26 | const { |
| 27 | isDirty, |
| 28 | dirtyFields, |
| 29 | touchedFields, |
| 30 | isSubmitted, |
| 31 | isSubmitSuccessful, |
| 32 | submitCount, |
| 33 | isValid, |
| 34 | } = useFormState({ |
| 35 | control, |
| 36 | }); |
| 37 | |
| 38 | return ( |
| 39 | <p id="state"> |
| 40 | {JSON.stringify({ |
| 41 | isDirty, |
| 42 | touched: Object.keys(touchedFields), |
| 43 | dirty: Object.keys(dirtyFields), |
| 44 | isSubmitted, |
| 45 | isSubmitSuccessful, |
| 46 | submitCount, |
| 47 | isValid, |
| 48 | })} |
| 49 | </p> |
| 50 | ); |
| 51 | }; |
| 52 | |
| 53 | export const UseFormState: React.FC = () => { |
| 54 | const { register, handleSubmit, control, reset } = useForm<FormInputs>({ |
nothing calls this directly
no test coverage detected