added fallback icon in IconComponent

This commit is contained in:
anovazzi1 2023-07-14 15:27:53 -03:00
commit 18820facbb

View file

@ -2,12 +2,12 @@ import { IconComponentProps, IconProps } from "../../types/components";
import { nodeIconsLucide, svgIcons } from "../../utils"; import { nodeIconsLucide, svgIcons } from "../../utils";
export function IconFromLucide({ name }: IconProps): JSX.Element { export function IconFromLucide({ name }: IconProps): JSX.Element {
const TargetIcon = nodeIconsLucide[name]; const TargetIcon = nodeIconsLucide[name] ?? nodeIconsLucide["unknown"];
return <TargetIcon />; return <TargetIcon />;
} }
export function IconFromSvg({ name }: IconProps): JSX.Element { export function IconFromSvg({ name }: IconProps): JSX.Element {
const TargetSvg = svgIcons[name]; const TargetSvg = svgIcons[name] ?? nodeIconsLucide["unknown"];
return <TargetSvg />; return <TargetSvg />;
} }
@ -21,6 +21,7 @@ export default function IconComponent({
case "LUCIDE": case "LUCIDE":
return <IconFromLucide name={name} />; return <IconFromLucide name={name} />;
default: default:
return; console.error("IconComponent: invalid method");
return <IconFromLucide name={"unknown"} />;
} }
} }