({
control,
index,
unregister,
}: {
control: Control<FormInputs>;
unregister: UseFormReturn<FormInputs>['unregister'];
index: number;
fields: T;
})
| 15 | }; |
| 16 | |
| 17 | const ConditionField = <T extends any[]>({ |
| 18 | control, |
| 19 | index, |
| 20 | unregister, |
| 21 | }: { |
| 22 | control: Control<FormInputs>; |
| 23 | unregister: UseFormReturn<FormInputs>['unregister']; |
| 24 | index: number; |
| 25 | fields: T; |
| 26 | }) => { |
| 27 | const output = useWatch({ |
| 28 | name: 'data', |
| 29 | control, |
| 30 | }); |
| 31 | |
| 32 | React.useEffect(() => { |
| 33 | return () => { |
| 34 | unregister(`data.${index}.conditional` as const, { |
| 35 | keepDirty: true, |
| 36 | keepTouched: true, |
| 37 | }); |
| 38 | }; |
| 39 | }, [unregister, index]); |
| 40 | |
| 41 | return output?.[index]?.name === 'bill' ? ( |
| 42 | <input {...control.register(`data.${index}.conditional`)} /> |
| 43 | ) : null; |
| 44 | }; |
| 45 | |
| 46 | const UseFieldArrayUnregister: React.FC = () => { |
| 47 | const { |
nothing calls this directly
no test coverage detected
searching dependent graphs…