Skip to content

Commit 29f03e8

Browse files
committed
fix: safeguard if channel does not exist
1 parent 93f43c0 commit 29f03e8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

package/src/components/AITypingIndicatorView/hooks/useAIState.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ export const AIStates = {
2323
export const useAIState = <
2424
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
2525
>(
26-
channel: Channel<StreamChatGenerics>,
26+
channel?: Channel<StreamChatGenerics>,
2727
) => {
2828
const [aiState, setAiState] = useState<AIStatesEnum>(AIStatesEnum.Idle);
2929

3030
useEffect(() => {
31+
if (!channel) {
32+
return;
33+
}
34+
3135
const indicatorChangedListener = channel.on(
3236
'ai_indicator_changed',
3337
(event: Event<StreamChatGenerics>) => {

0 commit comments

Comments
 (0)