Add error boundary to ChatModerationDetailsModal. For #2811
This commit is contained in:
parent
9162386495
commit
7cb5773a97
@ -3,9 +3,11 @@ import { FC, useEffect, useState } from 'react';
|
|||||||
import format from 'date-fns/format';
|
import format from 'date-fns/format';
|
||||||
import { ColumnsType } from 'antd/lib/table';
|
import { ColumnsType } from 'antd/lib/table';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
|
import { ErrorBoundary } from 'react-error-boundary';
|
||||||
import ChatModeration from '../../../services/moderation-service';
|
import ChatModeration from '../../../services/moderation-service';
|
||||||
import styles from './ChatModerationDetailsModal.module.scss';
|
import styles from './ChatModerationDetailsModal.module.scss';
|
||||||
import { formatUAstring } from '../../../utils/format';
|
import { formatUAstring } from '../../../utils/format';
|
||||||
|
import { ComponentError } from '../../ui/ComponentError/ComponentError';
|
||||||
|
|
||||||
const { Panel } = Collapse;
|
const { Panel } = Collapse;
|
||||||
|
|
||||||
@ -148,6 +150,16 @@ export const ChatModerationDetailsModal: FC<ChatModerationDetailsModalProps> = (
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
|
<ErrorBoundary
|
||||||
|
// eslint-disable-next-line react/no-unstable-nested-components
|
||||||
|
fallbackRender={({ error, resetErrorBoundary }) => (
|
||||||
|
<ComponentError
|
||||||
|
componentName="ChatModerationDetailsModal"
|
||||||
|
message={error.message}
|
||||||
|
retryFunction={resetErrorBoundary}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
>
|
||||||
<Spin spinning={loading}>
|
<Spin spinning={loading}>
|
||||||
<UserColorBlock color={displayColor} />
|
<UserColorBlock color={displayColor} />
|
||||||
{scopes?.map(scope => (
|
{scopes?.map(scope => (
|
||||||
@ -181,5 +193,6 @@ export const ChatModerationDetailsModal: FC<ChatModerationDetailsModalProps> = (
|
|||||||
</Collapse>
|
</Collapse>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
</Spin>
|
</Spin>
|
||||||
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user