feat(SocialLink): add fallback to FaExternalLinkAlt

this will be used, when no iconName is provided
This commit is contained in:
Danny Koppenhagen
2021-10-26 19:36:20 +02:00
committed by Bastian
parent 5a5dbee6f5
commit c8a3b528b8

View File

@@ -7,6 +7,7 @@ import {
FaYoutube,
FaGithub,
FaInstagram,
FaExternalLinkAlt
} from "react-icons/fa";
const icons = {
@@ -25,9 +26,7 @@ export interface Props {
}
const SocialLink: React.FC<Props> = ({ href, iconName }) => {
const Icon = icons[iconName];
if (Icon) {
const Icon = icons[iconName] || FaExternalLinkAlt;
return (
<a
href={href}
@@ -39,9 +38,6 @@ const SocialLink: React.FC<Props> = ({ href, iconName }) => {
<Icon className="social-icon" />
</a>
);
}
console.error(`The iconname is unknown: ${iconName}`);
return null;
};
export default SocialLink;