Type '{ children: string; key: string; }' is not assignable to type 'IntrinsicAttributes & FilterTagPropsType'.
Property 'children' does not exist on type 'IntrinsicAttributes & FilterTagPropsType'.ts(2322)
export const Filter: React.FC<PropsType> = ({ title, tags }) => {
return (
<div>
<Text style={{ marginRight: 40, fontSize: 15, fontWeight: 500 }}>
{title} :{" "}
</Text>
{tags.map((t, index) => {
if (index === tags.length - 1)
return <FilterTag key={`filter${index}`}>{t}</FilterTag>; // ====>报错
return (
<span key={`filter${index}`}>
<FilterTag>{t}</FilterTag>
<Divider type="vertical" />
</span>
);
})}
</div>
);
};
解决办法:给子组件FilterTag手动加完善类型:
interface FilterTagPropsType {
children?: string;
key?: string;
}