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 } }