@@ -33,7 +33,7 @@ import {
3333import { nanoid } from 'nanoid' ;
3434import clsx from 'clsx' ;
3535
36- import { channelReducer , ChannelStateReducer , initialState } from './channelState' ;
36+ import { initialState , makeChannelReducer } from './channelState' ;
3737import { useCreateChannelStateContext } from './hooks/useCreateChannelStateContext' ;
3838import { useCreateTypingContext } from './hooks/useCreateTypingContext' ;
3939import { useEditMessageHandler } from './hooks/useEditMessageHandler' ;
@@ -378,7 +378,9 @@ const ChannelInner = <
378378
379379 const notificationTimeouts = useRef < Array < NodeJS . Timeout > > ( [ ] ) ;
380380
381- const [ state , dispatch ] = useReducer < ChannelStateReducer < StreamChatGenerics > > (
381+ const channelReducer = useMemo ( ( ) => makeChannelReducer < StreamChatGenerics > ( ) , [ ] ) ;
382+
383+ const [ state , dispatch ] = useReducer (
382384 channelReducer ,
383385 // channel.initialized === false if client.channel().query() was not called, e.g. ChannelList is not used
384386 // => Channel will call channel.watch() in useLayoutEffect => state.loading is used to signal the watch() call state
@@ -392,7 +394,7 @@ const ChannelInner = <
392394 const isMounted = useIsMounted ( ) ;
393395
394396 const originalTitle = useRef ( '' ) ;
395- const lastRead = useRef < Date | undefined > ( ) ;
397+ const lastRead = useRef < Date | undefined > ( undefined ) ;
396398 const online = useRef ( true ) ;
397399
398400 const channelCapabilitiesArray = channel . data ?. own_capabilities as string [ ] ;
0 commit comments