How do I add material Icons to an array and pass it through props

etranz

I am working on a project with react, typescript and material icons

I want to add my material icons to an array and pass it through props

but it shows me the letters(string) of the icon

example is in this code which it displays on the browser is

export interface IDashboard {
  dashboardItems: {
    color: string;
    count: number;
    itemName: string;
    icon?: any;
    backgroundColor: string;
  }[];
}  

Dashboard

import { IDashboard as IState } from "../utils/Types";
const Dashboard = () => {
      const dashboardItems: IState['dashboardItems'] = [
        {
          color: "white",
          count: 5,
          itemName: "Users",
          icon: "<GroupIcon />",
          backgroundColor: "#373793",
        },
      ];
 return (
       <DashboardItems dashboardItems={ dashboardItems } />

 )
}

DashboardItems

import { IDashboard as IProps} from "../utils/Types";
import GroupIcon from "@material-ui/icons/Group";
const DashboardItems: React.FC<IProps> = ({ dashboardItems }) => {
  return (
     <div>{dashboardItem.icon}</div>
)}

How do I make it show Icon instead of letters(string)

FdM

In the IDashboard change the type of icon to JSX.Element and in the dashboardItems just remove the apostrophe from you component icon: <GroupIcon />, .

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How Do I pass props into a component that's in an array?

How do I correctly configure the material icons components to display icons?

How do I pass the values of an Array through Android Intents?

How to pass Data From React Router through props? I am unable to do it

How to pass an array to material-ui dataSource props

How do I pass both event and props?

How do I pass props callback to a Route?

How do I pass the props to DrawerItem Component?

How do I add icons to a menubar in uwp

How do I add icons to buttons?

MDL - How to add material icons?

Material UI - How Do I Pass In Styles Through the Select Component To Change The Popover Menu Look?

How can I pass props through an anchor tag?

How to pass icons as props in react with typescript

How to pass props through Link?

How to pass props through Link

how to pass props through <Link>

How do I override icons in Material UI DataGrid?

how can i populate an axios get data array and pass it to a Vuejs component props to do list rendering in the component

How do I pass an objectId through a URL?

Unable to pass/access array index through props

How can I cycle through an array of images using state/props?

How to pass props through this.props.children() not this.props.children

How do i loop through and array of an array

In Reactjs, how can i pass two props with one of them is array

How do I use material icons in my Android Studio project, using the material dependency?

How to pass props to the inputComponent material-ui?

In JavaScript, when looping through a FOR loop, how do I pass the value of the item in an array to an anonymous function?

How do I pass my Array of Objects through dispatch using redux