Add error boundary to FollowersCollection. For #2811

This commit is contained in:
Gabe Kangas 2023-03-12 23:03:22 -07:00
parent 274aeb8be6
commit 02e937c351
No known key found for this signature in database
GPG Key ID: 4345B2060657F330

View File

@ -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,6 +69,16 @@ export const FollowerCollection: FC<FollowerCollectionProps> = ({ name, onFollow
} }
return ( return (
<ErrorBoundary
// eslint-disable-next-line react/no-unstable-nested-components
fallbackRender={({ error, resetErrorBoundary }) => (
<ComponentError
componentName="FollowerCollection"
message={error.message}
retryFunction={resetErrorBoundary}
/>
)}
>
<div className={styles.followers} id="followers-collection"> <div className={styles.followers} id="followers-collection">
<Row wrap gutter={[10, 10]} className={styles.followerRow}> <Row wrap gutter={[10, 10]} className={styles.followerRow}>
{followers.map(follower => ( {followers.map(follower => (
@ -89,5 +101,6 @@ export const FollowerCollection: FC<FollowerCollectionProps> = ({ name, onFollow
hideOnSinglePage hideOnSinglePage
/> />
</div> </div>
</ErrorBoundary>
); );
}; };