()
| 4 | let renderCounter = 0; |
| 5 | |
| 6 | const SetValue: React.FC = () => { |
| 7 | const { |
| 8 | register, |
| 9 | setValue, |
| 10 | handleSubmit, |
| 11 | formState: { errors }, |
| 12 | } = useForm<{ |
| 13 | firstName: string; |
| 14 | lastName: string; |
| 15 | age: string; |
| 16 | trigger: string; |
| 17 | checkbox: boolean; |
| 18 | checkboxArray: string[]; |
| 19 | radio: string; |
| 20 | select: string; |
| 21 | multiple: string[]; |
| 22 | array: string[]; |
| 23 | object: { |
| 24 | firstName: string; |
| 25 | lastName: string; |
| 26 | middleName: string; |
| 27 | }; |
| 28 | nestedValue: string[]; |
| 29 | }>(); |
| 30 | |
| 31 | useEffect(() => { |
| 32 | register('lastName', { required: true }); |
| 33 | setValue('firstName', 'wrong', { shouldDirty: true }); |
| 34 | setValue('age', '2', { shouldDirty: true }); |
| 35 | setValue('trigger', '', { shouldDirty: true, shouldValidate: true }); |
| 36 | setValue('checkbox', true, { shouldDirty: true }); |
| 37 | setValue('checkboxArray', ['2', '3'], { |
| 38 | shouldDirty: true, |
| 39 | shouldValidate: true, |
| 40 | }); |
| 41 | setValue('radio', 'radio', { shouldDirty: true }); |
| 42 | setValue('select', 'a', { shouldDirty: true }); |
| 43 | setValue('multiple', ['a', 'b'], { shouldDirty: true }); |
| 44 | setValue('array', ['array.0', 'array.1', 'array.2'], { |
| 45 | shouldDirty: true, |
| 46 | }); |
| 47 | setValue( |
| 48 | 'object', |
| 49 | { |
| 50 | firstName: 'firstName', |
| 51 | lastName: 'lastName', |
| 52 | middleName: 'middleName', |
| 53 | }, |
| 54 | { shouldDirty: true }, |
| 55 | ); |
| 56 | setValue('nestedValue', [], { |
| 57 | shouldValidate: true, |
| 58 | shouldDirty: true, |
| 59 | }); |
| 60 | }, [register, setValue]); |
| 61 | |
| 62 | renderCounter++; |
| 63 |
nothing calls this directly
no test coverage detected