refactor: update WebSocket connection effect to depend on token changes for reconnection

This commit is contained in:
Haileyesus
2026-02-02 12:20:51 +03:00
parent 0b4d048e9a
commit a35140bc5e

View File

@@ -46,7 +46,7 @@ const useWebSocketProviderState = (): WebSocketContextType => {
wsRef.current.close(); wsRef.current.close();
} }
}; };
}, []); // Keep dependency array but add proper cleanup }, [token]); // everytime token changes, we reconnect
const connect = useCallback(() => { const connect = useCallback(() => {
if (unmountedRef.current) return; // Prevent connection if unmounted if (unmountedRef.current) return; // Prevent connection if unmounted