I'm having trouble with a particular code snippet:
type MenuItemType = { name: string; link: string };
There's also an array of these types:
const menuItems: MenuItemType[] = [
{ name: "FAQ", link: "/faq" },
{ name: "Terms of use", link: "/terms" },
{ name: "Cookie policy", link: "/cookie-policy" },
{ name: "Privacy policy", link: "/privacy-policy" },
{ name: "Subscription", link: "/subscription" },
];
I have a component that accepts props of the same type:
function ListItem({ name, link }: MenuItemType) {
return (
<li className="text-xs mr-14 last:mr-0">
<Link href={link}>
<a>{name}</a>
</Link>
</li>
);
}
The ListItem Component is used in a map function, and TypeScript is showing an error.
https://i.sstatic.net/0v4DG.png
Any ideas on what could be wrong?