From 593a7faa3680e2c70819d7ee769eb7a8b293d39d Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sun, 12 Mar 2023 21:40:36 -0700 Subject: [PATCH] Add error boundaries to MobileContent. For #2811 --- web/components/ui/Content/MobileContent.tsx | 39 +++++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/web/components/ui/Content/MobileContent.tsx b/web/components/ui/Content/MobileContent.tsx index 91a50e8d3..a8557b0fd 100644 --- a/web/components/ui/Content/MobileContent.tsx +++ b/web/components/ui/Content/MobileContent.tsx @@ -1,6 +1,7 @@ import React, { ComponentType, FC } from 'react'; import dynamic from 'next/dynamic'; import { Skeleton, TabsProps } from 'antd'; +import { ErrorBoundary } from 'react-error-boundary'; import { SocialLink } from '../../../interfaces/social-link.model'; import styles from './Content.module.scss'; import { CustomPageContent } from '../CustomPageContent/CustomPageContent'; @@ -9,6 +10,7 @@ import { ChatMessage } from '../../../interfaces/chat-message.model'; import { CurrentUser } from '../../../interfaces/current-user'; import { ActionButtonMenu } from '../../action-buttons/ActionButtonMenu/ActionButtonMenu'; import { ExternalAction } from '../../../interfaces/external-action'; +import { ComponentError } from '../ComponentError/ComponentError'; export type MobileContentProps = { name: string; @@ -61,6 +63,14 @@ type ChatContentProps = { currentUser: CurrentUser; }; +const ComponentErrorFallback = ({ error, resetErrorBoundary }) => ( + +); + const ChatContent: FC = ({ showChat, chatEnabled, messages, currentUser }) => { const { id, displayName } = currentUser; @@ -146,17 +156,24 @@ export const MobileContent: FC = ({ ); return ( -
- {items.length > 1 ? ( - - ) : ( - aboutTabContent + ( + )} -
+ > +
+ {items.length > 1 ? ( + + ) : ( + aboutTabContent + )} +
+ ); };