Skip to content

Commit 8309c6b

Browse files
committed
Fix crash and wrap component in error boundary
1 parent 2eaa238 commit 8309c6b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/UI/components/single/BigPanel.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import BattleRoom from '../rooms/BattleRoom';
1414
import PmRoom from '../rooms/PmRoom';
1515
import HtmlRoom from '../rooms/HtmlRoom';
1616
import { useClientStore } from '@/client/client';
17+
import { ErrorBoundary } from 'react-error-boundary';
1718

1819
export default function BigPanel(props: Readonly<HTMLAttributes<'div'>>) {
1920
const room = useClientStore(state => state.currentRoom);
@@ -60,8 +61,12 @@ export default function BigPanel(props: Readonly<HTMLAttributes<'div'>>) {
6061
>
6162
<div className={'dark:bg-gray-300 flex flex-col w-full max-w-full'}>
6263
<div className="flex-grow flex-shrink min-h-0">
63-
<Chat
64-
/>
64+
<ErrorBoundary fallbackRender={({ error: e }) => {
65+
console.error(e);
66+
return <div className="text-red-400">Error displaying messages</div>;
67+
}}>
68+
<Chat />
69+
</ErrorBoundary>
6570
</div>
6671
<div className="flex-grow">
6772
<ChatBox className='p-2' />

src/UI/components/single/Chat.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export default function Chat(props: Readonly<HTMLAttributes<HTMLDivElement>>) {
8585
>
8686
</div>
8787
</div>
88-
{' '}
8988
</div>
9089
);
9190
}

0 commit comments

Comments
 (0)