diff --git a/apps/dispatch/app/dispatch/_components/navbar/_components/Connection.tsx b/apps/dispatch/app/dispatch/_components/navbar/_components/Connection.tsx index cdb98ab8..7202b934 100644 --- a/apps/dispatch/app/dispatch/_components/navbar/_components/Connection.tsx +++ b/apps/dispatch/app/dispatch/_components/navbar/_components/Connection.tsx @@ -49,6 +49,13 @@ export const ConnectionBtn = () => { }; }, [form.logoffTime, connection.connectedDispatcher]); + useEffect(() => { + // Disconnect the socket when the component unmounts + return () => { + connection.disconnect(); + }; + }, [connection.disconnect]); + return (