diff --git a/client/ui/App.tsx b/client/ui/App.tsx index 1f1ebb0..5130cb8 100644 --- a/client/ui/App.tsx +++ b/client/ui/App.tsx @@ -173,7 +173,8 @@ export default function App() { } { isShowChatFragment && + target={currentChatId} + key={currentChatId} /> } diff --git a/client/ui/AppMobile.tsx b/client/ui/AppMobile.tsx index 8820ccb..f8f0c71 100644 --- a/client/ui/AppMobile.tsx +++ b/client/ui/AppMobile.tsx @@ -109,6 +109,7 @@ export default function AppMobile() { setIsShowChatFragment(false)} + key={currentChatId} target={currentChatId} /> diff --git a/client/ui/useEventListener.ts b/client/ui/useEventListener.ts index 169f29f..8e92b09 100644 --- a/client/ui/useEventListener.ts +++ b/client/ui/useEventListener.ts @@ -3,6 +3,6 @@ import * as React from 'react' export default function useEventListener(ref: React.MutableRefObject, eventName: string, callback: (event: Event) => void) { React.useEffect(() => { ref.current!.addEventListener(eventName, callback) - return () => ref.current!.removeEventListener(eventName, callback) + return () => ref.current?.removeEventListener(eventName, callback) }, [ref, eventName, callback]) }