【发布时间】:2021-05-10 09:59:12
【问题描述】:
我有一个按钮组件,我正在尝试使用type 编写道具类型,我在控制台中看到了这个错误。有人可以帮忙吗?
Type '{ children: string; label: string; onClick: () => void; }' is not assignable to type 'IntrinsicAttributes & Props'.
Property 'onClick' does not exist on type 'IntrinsicAttributes & Props'. TS2322
摘自我的代码
type Props = {
label: string;
children: ReactNode;
};
const Button = ({ label, children, ...props }: Props) => (
<button label={label} {...props}>
{children}
</button>
);
【问题讨论】:
标签: javascript reactjs typescript ecmascript-6