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,31 +1,50 @@
|
|||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
|
import { ErrorBoundary } from 'react-error-boundary';
|
||||||
import { SocialLink } from '../../../interfaces/social-link.model';
|
import { SocialLink } from '../../../interfaces/social-link.model';
|
||||||
|
import { ComponentError } from '../ComponentError/ComponentError';
|
||||||
import styles from './SocialLinks.module.scss';
|
import styles from './SocialLinks.module.scss';
|
||||||
|
|
||||||
export type SocialLinksProps = {
|
export type SocialLinksProps = {
|
||||||
links: SocialLink[];
|
links: SocialLink[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SocialLinks: FC<SocialLinksProps> = ({ links }) => (
|
export const SocialLinks: FC<SocialLinksProps> = ({ links }) => {
|
||||||
<div className={styles.links}>
|
if (!links?.length) {
|
||||||
{links.map(link => (
|
return null;
|
||||||
<a
|
}
|
||||||
key={link.platform}
|
|
||||||
href={link.url}
|
return (
|
||||||
className={styles.link}
|
<ErrorBoundary
|
||||||
target="_blank"
|
// eslint-disable-next-line react/no-unstable-nested-components
|
||||||
// eslint-disable-next-line react/no-invalid-html-attribute
|
fallbackRender={({ error, resetErrorBoundary }) => (
|
||||||
rel="noreferrer me"
|
<ComponentError
|
||||||
>
|
componentName="SocialLinks"
|
||||||
<Image
|
message={error.message}
|
||||||
src={link.icon || '/img/platformlogos/default.svg'}
|
retryFunction={resetErrorBoundary}
|
||||||
alt={link.platform}
|
|
||||||
className={styles.link}
|
|
||||||
width="30"
|
|
||||||
height="30"
|
|
||||||
/>
|
/>
|
||||||
</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>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user