From cf10ab97741a890462e7f4b77a231a4617887511 Mon Sep 17 00:00:00 2001 From: rokku-x <39764747+rokku-x@users.noreply.github.com> Date: Thu, 7 Jan 2021 07:36:19 +0800 Subject: [PATCH] Camera Timeout React Memory Leak The timer is not cleared when the component is unmounted during the set time period of camera timeout. --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c739d96..123774d 100644 --- a/index.js +++ b/index.js @@ -132,7 +132,7 @@ export default class QRCodeScanner extends Component { isAuthorizationChecked: false, disableVibrationByUser: false, }; - + this.timer = null; this._scannerTimeout = null; this._handleBarCodeRead = this._handleBarCodeRead.bind(this); } @@ -178,6 +178,10 @@ export default class QRCodeScanner extends Component { if (this._scannerTimeout !== null) { clearTimeout(this._scannerTimeout); } + if (this.timer !== null) { + clearTimeout(this.timer); + } + this.timer = null; this._scannerTimeout = null; }