From 738915ee845b58e8701d4548b2d738d178d164ed Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Wed, 20 Sep 2023 09:39:15 +0300 Subject: [PATCH] fix: fix aws icons not being displayed Closes #1399 --- src/components/Icon/index.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Icon/index.tsx b/src/components/Icon/index.tsx index e365359a3f..52659c89cc 100644 --- a/src/components/Icon/index.tsx +++ b/src/components/Icon/index.tsx @@ -65,16 +65,16 @@ function findByName(name?: string) { return undefined; } if (getIconsForAWSEvents(name)) { - return getIconsForAWSEvents(name); + name = getIconsForAWSEvents(name); } if (aliases[name as keyof typeof aliases]) { name = aliases[name as keyof typeof aliases]; } - name = name.replaceAll("::", "-").replaceAll("--", "-").toLowerCase(); + name = name?.replaceAll("::", "-").replaceAll("--", "-").toLowerCase(); if (aliases[name as keyof typeof aliases]) { name = aliases[name as keyof typeof aliases]; } - var icon = Icons[name.toLowerCase() as keyof typeof Icons]; + var icon = Icons[name?.toLowerCase() as keyof typeof Icons]; if (icon == null) { icon = Icons[("aws-" + name) as keyof typeof Icons]; } @@ -86,7 +86,7 @@ function findByName(name?: string) { } for (let prefix in prefixes) { - if (name.toLowerCase().startsWith(prefix)) { + if (name?.toLowerCase().startsWith(prefix)) { icon = Icons[prefixes[prefix as keyof typeof prefixes] as keyof typeof Icons]; } @@ -131,7 +131,7 @@ export const Icon: React.FC = memo( icon = name; } else if (!isEmpty(name) || !isEmpty(secondary)) { icon = findByName(name); - if (icon == null) { + if (!icon) { icon = findByName(secondary); } if (icon == null && reactIcons[secondary as keyof typeof reactIcons]) {