Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Commit

Permalink
fix: clear timeout to fix memory leak
Browse files Browse the repository at this point in the history
Camera Timeout React Memory Leak Fix
  • Loading branch information
moaazsidat committed Jan 13, 2021
2 parents 565cb3b + cf10ab9 commit e44250a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit e44250a

Please sign in to comment.