Ошибка TS2740 при инициализация массива
Ошибка: TS2740: Type '{ props: { icon: string; }; }' is missing the following properties from type 'IconLink': render, context, setState, forceUpdate, and 2 more.
(ошибка на линии: "{props: {icon: "https://"}}", в файле: App.tsx)
P.s: <IconLink icon=""/> - работает
Файл IconLink.tsx:
interface IconLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement>{
icon: string
}
class IconLink extends React.Component<IconLinkProps> {
render() {
return (
<a {...this.props}>
<img src={this.props.icon} alt=" "/>
{this.props.children}
</a>
);
}
}
Файл App.tsx (с ошибкой)
let array: IconLink[] = [
{props: {icon: "https://"}}
];
Ответы (1 шт):
Автор решения: Werckut
→ Ссылка
const navs: IconLink[] = [
new IconLink({icon: ""})
]
Это решило проблему