I have converted the following arrow function destructure to Typescript, however I don't understand how to interpret the last item: icon: Icon. This item is not imported or declared.
Original JavaScript:
const NavbarDropdown = ({
children,
count,
showBadge,
header,
footer,
icon: Icon
}) => (
<UncontrolledDropdown nav inNavbar className="mr-2">
<DropdownToggle nav className="nav-icon dropdown-toggle">
<div className="position-relative">
<Icon className="align-middle" size={18} />
Converted to TypeScript except an error with {icon: Icon} where Icon is neither imported nor declared anywhere except within the body of the function:
const NavbarDropdown = (
{children} : {children: string},
{count} : {count: number},
{showBadge} : {showBadge: boolean},
{header} : { header: string},
{footer} : { footer: string},
{icon: Icon},
) => (
<UncontrolledDropdown nav inNavbar className="mr-2">
<DropdownToggle nav className="nav-icon dropdown-toggle">
<div className="position-relative">
<Icon className="align-middle" size={18} />
Update: I understand what this group is referring to regarding Icon/icon and I still cannot find anywhere Icon gets imported or declared. As suggested here is the code snippet of the NavbarDropdown call:
<Collapse navbar>
<Nav className="ml-auto" navbar>
<NavbarDropdown
header="New Messages"
footer="Show all messages"
icon={MessageCircle}
count={messages.length}
showBadge
>
{messages.map((item, key) => {
return (
<NavbarDropdownItem
key={key}
icon={
<img
className="avatar img-fluid rounded-circle"
src={item.avatar}
alt={item.name}
/>
}
title={item.name}
description={item.description}
time={item.time}
spacing
/>
);
})}
</NavbarDropdown>
const NavbarDropdown: React.FC<MyPropsInterface> = ...{children, count,...}: {children:string, count:number,...What you have done instead is create a function multiple parameters, instead of a function with 1 parameter that you destruct.