From 81f2950c192cf7da7556f98f4ab33a116f17849c Mon Sep 17 00:00:00 2001 From: Pavel Prichodko <14926950+prichodko@users.noreply.github.com> Date: Tue, 23 Aug 2022 18:13:25 +0200 Subject: [PATCH] fix optional path match --- packages/status-react/src/protocol/use-active-chat.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/status-react/src/protocol/use-active-chat.tsx b/packages/status-react/src/protocol/use-active-chat.tsx index 3107874e..e3531572 100644 --- a/packages/status-react/src/protocol/use-active-chat.tsx +++ b/packages/status-react/src/protocol/use-active-chat.tsx @@ -5,8 +5,11 @@ import { useProtocol } from './provider' export const useActiveChat = () => { const { client } = useProtocol() - const { params } = useMatch(':id')! - const chatId = params.id! + const path = useMatch(':id') - return client.community.getChat(chatId) + if (!path?.params.id) { + return + } + + return client.community.getChat(path.params.id) }