Browse Source

Add error boundary to FollowersCollection. For #2811

pull/2815/head
Gabe Kangas 2 years ago
parent
commit
02e937c351
No known key found for this signature in database
GPG Key ID: 4345B2060657F330
  1. 13
      web/components/ui/followers/FollowerCollection/FollowerCollection.tsx

13
web/components/ui/followers/FollowerCollection/FollowerCollection.tsx

@ -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>
); );
}; };

Loading…
Cancel
Save