【发布时间】:2021-04-22 07:58:57
【问题描述】:
我正在尝试在广播和广播组上绑定一个反应挂钩表单。但是,我遇到以下问题
Property 'Group' does not exist on type 'ForwardRefExoticComponent<InputProps & RefAttributes<HTMLInputElement>>'. TS2339
这是代码
import { Radio as $Radio } from 'antd';
import { RadioProps, RadioChangeEvent } from 'antd/lib/radio';
import { Controller } from 'react-hook-form';
import { InputProps } from './types';
const Radio = React.forwardRef<HTMLInputElement, InputProps>((props: InputProps, ref) => {
const { id, name, label, control } = props;
return (
<>
<Controller
name={name}
control={control}
render={(controlProps: RadioProps) => {
const { onChange } = controlProps;
return (
<$Radio
{...controlProps}
id={id}
checked={controlProps.value}
value={controlProps.value}
className="radio"
>
{label}
</$Radio>
);
}}
/>
</>
);
});
export default Radio;
Radio.Group = (props: InputProps) => {
const { id, name, label, control } = props;
return (
<>
<Controller
name={name}
control={control}
render={(controlProps: RadioProps) => {
const { onChange } = controlProps;
return (
<$Radio.Group
{...controlProps}
id={id}
checked={controlProps.value}
value={controlProps.value}
className="radio"
>
{label}
</$Radio.Group>
);
}}
/>
</>
);
}
我无法弄清楚为什么我会遇到这样的问题。如何在 Radio Group 上绑定 react-hook-form ?
【问题讨论】:
标签: javascript reactjs typescript antd react-hook-form