Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Fix exception thrown with zero links. Closes #2833

Gabe Kangas69462ae15bd2
diff --git a/web/components/ui/SocialLinks/SocialLinks.tsx b/web/components/ui/SocialLinks/SocialLinks.tsx
index 7317973709..df9d60cce8 100644
--- a/web/components/ui/SocialLinks/SocialLinks.tsx
+++ b/web/components/ui/SocialLinks/SocialLinks.tsx
@@ -1,31 +1,50 @@
import Image from 'next/image';
import { FC } from 'react';
+import { ErrorBoundary } from 'react-error-boundary';
import { SocialLink } from '../../../interfaces/social-link.model';
+import { ComponentError } from '../ComponentError/ComponentError';
import styles from './SocialLinks.module.scss';
export type SocialLinksProps = {
links: SocialLink[];
};
-export const SocialLinks: FC<SocialLinksProps> = ({ links }) => (
- <div className={styles.links}>
- {links.map(link => (
- <a
- key={link.platform}
- href={link.url}
- className={styles.link}
- target="_blank"
- // eslint-disable-next-line react/no-invalid-html-attribute
- rel="noreferrer me"
- >
- <Image
- src={link.icon || '/img/platformlogos/default.svg'}
- alt={link.platform}
- className={styles.link}
- width="30"
- height="30"
+export const SocialLinks: FC<SocialLinksProps> = ({ links }) => {
+ if (!links?.length) {
+ return null;
+ }
+
+ return (
+ <ErrorBoundary
+ // eslint-disable-next-line react/no-unstable-nested-components
+ fallbackRender={({ error, resetErrorBoundary }) => (
+ <ComponentError
+ componentName="SocialLinks"
+ message={error.message}
+ retryFunction={resetErrorBoundary}
/>
- </a>
- ))}
- </div>
-);
+ )}
+ >
+ <div className={styles.links}>
+ {links?.map(link => (
+ <a
+ key={link.platform}
+ href={link.url}
+ className={styles.link}
+ target="_blank"
+ // eslint-disable-next-line react/no-invalid-html-attribute
+ rel="noreferrer me"
+ >
+ <Image
+ src={link.icon || '/img/platformlogos/default.svg'}
+ alt={link.platform}
+ className={styles.link}
+ width="30"
+ height="30"
+ />
+ </a>
+ ))}
+ </div>
+ </ErrorBoundary>
+ );
+};