mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
Add error boundary to FollowersCollection. For #2811
This commit is contained in:
parent
274aeb8be6
commit
02e937c351
@ -1,9 +1,11 @@
|
|||||||
import { FC, useEffect, useState } from 'react';
|
import { FC, useEffect, useState } from 'react';
|
||||||
import { Col, Pagination, Row, Skeleton } from 'antd';
|
import { Col, Pagination, Row, Skeleton } from 'antd';
|
||||||
|
import { ErrorBoundary } from 'react-error-boundary';
|
||||||
import { Follower } from '../../../../interfaces/follower';
|
import { Follower } from '../../../../interfaces/follower';
|
||||||
import { SingleFollower } from '../SingleFollower/SingleFollower';
|
import { SingleFollower } from '../SingleFollower/SingleFollower';
|
||||||
import styles from './FollowerCollection.module.scss';
|
import styles from './FollowerCollection.module.scss';
|
||||||
import { FollowButton } from '../../../action-buttons/FollowButton';
|
import { FollowButton } from '../../../action-buttons/FollowButton';
|
||||||
|
import { ComponentError } from '../../ComponentError/ComponentError';
|
||||||
|
|
||||||
export type FollowerCollectionProps = {
|
export type FollowerCollectionProps = {
|
||||||
name: string;
|
name: string;
|
||||||
@ -67,27 +69,38 @@ export const FollowerCollection: FC<FollowerCollectionProps> = ({ name, onFollow
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.followers} id="followers-collection">
|
<ErrorBoundary
|
||||||
<Row wrap gutter={[10, 10]} className={styles.followerRow}>
|
// eslint-disable-next-line react/no-unstable-nested-components
|
||||||
{followers.map(follower => (
|
fallbackRender={({ error, resetErrorBoundary }) => (
|
||||||
<Col key={follower.link}>
|
<ComponentError
|
||||||
<SingleFollower key={follower.link} follower={follower} />
|
componentName="FollowerCollection"
|
||||||
</Col>
|
message={error.message}
|
||||||
))}
|
retryFunction={resetErrorBoundary}
|
||||||
</Row>
|
/>
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className={styles.followers} id="followers-collection">
|
||||||
|
<Row wrap gutter={[10, 10]} className={styles.followerRow}>
|
||||||
|
{followers.map(follower => (
|
||||||
|
<Col key={follower.link}>
|
||||||
|
<SingleFollower key={follower.link} follower={follower} />
|
||||||
|
</Col>
|
||||||
|
))}
|
||||||
|
</Row>
|
||||||
|
|
||||||
<Pagination
|
<Pagination
|
||||||
className={styles.pagination}
|
className={styles.pagination}
|
||||||
current={page}
|
current={page}
|
||||||
pageSize={ITEMS_PER_PAGE}
|
pageSize={ITEMS_PER_PAGE}
|
||||||
defaultPageSize={ITEMS_PER_PAGE}
|
defaultPageSize={ITEMS_PER_PAGE}
|
||||||
total={total}
|
total={total}
|
||||||
showSizeChanger={false}
|
showSizeChanger={false}
|
||||||
onChange={p => {
|
onChange={p => {
|
||||||
setPage(p);
|
setPage(p);
|
||||||
}}
|
}}
|
||||||
hideOnSinglePage
|
hideOnSinglePage
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user