@@ -407,7 +407,7 @@ const ChannelInner = <
407
407
const [ quotedMessage , setQuotedMessage ] = useState < StreamMessage < StreamChatGenerics > > ( ) ;
408
408
const [ channelUnreadUiState , _setChannelUnreadUiState ] = useState < ChannelUnreadUiState > ( ) ;
409
409
410
- const notificationTimeouts : Array < NodeJS . Timeout > = [ ] ;
410
+ const notificationTimeouts = useRef < Array < NodeJS . Timeout > > ( [ ] ) ;
411
411
412
412
const [ state , dispatch ] = useReducer < ChannelStateReducer < StreamChatGenerics > > (
413
413
channelReducer ,
@@ -641,15 +641,15 @@ const ChannelInner = <
641
641
channel . on ( handleEvent ) ;
642
642
}
643
643
} ) ( ) ;
644
+ const notificationTimeoutsRef = notificationTimeouts . current ;
644
645
645
646
return ( ) => {
646
647
if ( errored || ! done ) return ;
647
648
channel ?. off ( handleEvent ) ;
648
649
client . off ( 'connection.changed' , handleEvent ) ;
649
650
client . off ( 'connection.recovered' , handleEvent ) ;
650
- client . off ( 'user.updated' , handleEvent ) ;
651
651
client . off ( 'user.deleted' , handleEvent ) ;
652
- notificationTimeouts . forEach ( clearTimeout ) ;
652
+ notificationTimeoutsRef . forEach ( clearTimeout ) ;
653
653
} ;
654
654
// eslint-disable-next-line react-hooks/exhaustive-deps
655
655
} , [
@@ -671,7 +671,10 @@ const ChannelInner = <
671
671
/** MESSAGE */
672
672
673
673
// Adds a temporary notification to message list, will be removed after 5 seconds
674
- const addNotification = makeAddNotifications ( setNotifications , notificationTimeouts ) ;
674
+ const addNotification = useMemo (
675
+ ( ) => makeAddNotifications ( setNotifications , notificationTimeouts . current ) ,
676
+ [ ] ,
677
+ ) ;
675
678
676
679
// eslint-disable-next-line react-hooks/exhaustive-deps
677
680
const loadMoreFinished = useCallback (
0 commit comments