mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Fix exception thrown with zero links. Closes #2833
This commit is contained in:
parent
a2af4f5729
commit
7e4d147940
@ -1,15 +1,32 @@
|
||||
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 }) => (
|
||||
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}
|
||||
/>
|
||||
)}
|
||||
>
|
||||
<div className={styles.links}>
|
||||
{links.map(link => (
|
||||
{links?.map(link => (
|
||||
<a
|
||||
key={link.platform}
|
||||
href={link.url}
|
||||
@ -28,4 +45,6 @@ export const SocialLinks: FC<SocialLinksProps> = ({ links }) => (
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
</ErrorBoundary>
|
||||
);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user