From bd36e9f5ea5c6c0bea1df3c53ed8a51fb5bd892a Mon Sep 17 00:00:00 2001 From: Kitteh Date: Tue, 25 May 2021 12:41:02 +0100 Subject: [PATCH] Make QR scanner deinit properly. --- src/elements/QRScanner.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/elements/QRScanner.tsx b/src/elements/QRScanner.tsx index 9611794..5170ba4 100644 --- a/src/elements/QRScanner.tsx +++ b/src/elements/QRScanner.tsx @@ -16,6 +16,7 @@ export class QRScanner extends Component { videoElement = createRef(); stream: MediaStream; + qrScanner: QrScanner; componentDidMount(): void { void navigator.mediaDevices @@ -33,16 +34,15 @@ export class QRScanner extends Component { if (lastSeenValue == value) return; this.props.onScan(value); }); + this.qrScanner = qrScanner; void qrScanner.start(); }); } componentWillUnmount(): void { try { - this.stream.getTracks().forEach(function (track) { - track.stop(); - }); + this.qrScanner.destroy(); } catch (_) { - () => {}; + // Do Nothing } }