Home > Back-end >  How to declare react-icons icon in TS?
How to declare react-icons icon in TS?

Time:10-25

I created an array with name and icon. I have trouble with declaring icon.

  export const SidebarMenuList: SidebarMenu[] = [
  {
    name: "Discover",
    icon: <AiOutlineHome />,
    id: SidebarCategory.Discover,
  },
]

SidebarMenu interface ---

export interface SidebarMenu {
  name: string;
  icon: IconType;
  id: SidebarCategory;
}

I got error - JSX.Element type 'AiOutlineHome' does not have any construct or call signatures. How to fix this. Thank you!

CodePudding user response:

if you re using React Icons library you will need to import it

import { AiOutlineHome } from "react-icons/ai";

you can see on the documentation : https://react-icons.github.io/react-icons

  • Related