From e3453a1fe63fed5529f9cca9410b4ee934c19865 Mon Sep 17 00:00:00 2001 From: Josue Date: Mon, 12 Jul 2021 19:47:22 -0400 Subject: [PATCH] refactor(front-end): set rfb state to undefined when the VncDisplay component is unmounted --- striker-ui/components/Display/VncDisplay.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/striker-ui/components/Display/VncDisplay.tsx b/striker-ui/components/Display/VncDisplay.tsx index 5b927901..cfc1885f 100644 --- a/striker-ui/components/Display/VncDisplay.tsx +++ b/striker-ui/components/Display/VncDisplay.tsx @@ -57,12 +57,18 @@ const VncDisplay = (props: VncProps): JSX.Element => { if (!canvasRef.current) { /* eslint-disable consistent-return */ - return (): void => rfb.disconnect(); + return (): void => { + rfb.disconnect(); + setRfb(undefined); + }; } rfb.connect(url); - return (): void => rfb.disconnect(); + return (): void => { + rfb.disconnect(); + setRfb(undefined); + }; }, [rfb, encrypt, opts, url]); const handleMouseEnter = () => {