import { OverridableComponent } from "@mui/material/OverridableComponent"; const…
- User
import { OverridableComponent } from "@mui/material/OverridableComponent"; const SidebarListProps = { title: string, icon: OverridableComponent<SvgIconTypeMap<{}, "svg">>, styler: string, styleIcon: string, }; const SidebarList: React.FC = ({ title, icon: Icon, styler, styleIcon, }) => { return ( {title} ); };
export default SidebarList; correct this so it will be comaptible with typescript
- Assistant
import { OverridableComponent, SvgIconTypeMap } from "@mui/material"; import { FC } from "react";
interface SidebarListProps { title: string; icon: OverridableComponent<SvgIconTypeMap<{}, "svg">>; styler: string; styleIcon: string; }
const SidebarList: FC = ({ title, icon: Icon, styler, styleIcon, }: SidebarListProps) => { return ( {title} ); };
export default SidebarList;
- User
- Assistant
You should import the icons from "@mui/icons-material" instead of "@material-ui/icons". Also, you should specify the type of the icon prop in SidebarListProps as any, because SvgIconTypeMap can't be inferred from the imported icons.
Here's the corrected code:
import SidebarList from "./SidebarList"; import { LineStyle, Timeline, TrendingUp } from "@mui/icons-material"; const titleList = [ { title: "Dashboard" }, { title: "Quick Menu" }, { title: "Notifications" }, { title: "Staff" }, ]; const sidebarList = [ { title: "Home", icon: LineStyle, styler: "sidebarContainer__listItem active", styleIcon: "sidebarContainer__listIcon", }, { title: "Analytics", icon: Timeline, styler: "sidebarContainer__listItem", styleIcon: "sidebarContainer__listIcon", }, { title: "Sales", icon: TrendingUp, styler: "sidebarContainer__listItem", styleIcon: "sidebarContainer__listIcon", }, ]; interface SidebarProps {} const Sidebar: React.FC<SidebarProps> = ({}) => { return ( <div className="sidebar"> <div className="sidebarContainer"> {titleList.map((sidebar) => ( <div className="sidebarContainer__menu" key={sidebar.title}> <h3 className="sidebarContainer__title">{sidebar.title}</h3> {sidebarList.map((sidebarList) => ( <SidebarList title={sidebarList.title} icon={<sidebarList.icon />} styler={sidebarList.styler} styleIcon={sidebarList.styleIcon} key={sidebarList.title} /> ))} </div> ))} </div> </div> ); }; export default Sidebar;
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.