I would like to pass material UI icons from Sidebar.js to SidebarOption. The idea is to display sidebar options in sidebar passing in different MUI icons.
Sidebar.js
import React from "react";
import TwitterIcon from "@material-ui/icons/Twitter";
import SidebarOption from "./SidebarOption.js";
function Sidebar() {
return (
<div>
<SidebarOption Icon={TwitterIcon} text="Home" />
</div>
);
}
export default Sidebar;
SidebarOption.js
import React from "react";
function SidebarOption({ text, Icon }) {
return (
<div>
<Icon />
<h2>{text}</h2>
</div>
);
}
export default SidebarOption;
I got the error below. Icon is the problem. text works fine..