Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props) {
super(props);
const barcodeScannerType = props.barcodeScannerType
? props.barcodeScannerType
: 'qrCode';
this.state = {
barcodeScannerType: barcodeScannerType,
};
if (barcodeScannerType == 'qrCode') {
this.reader = new BrowserQRCodeReader();
} else if (barcodeScannerType == 'barcode') {
this.reader = new BrowserBarcodeReader();
} else if (barcodeScannerType == 'datamatrix') {
this.reader = new BrowserDatamatrixCodeReader();
} else {
throw new Error('Unknown barcodeScannerType: ' + barcodeScannerType);
}
}
_changeReader = () => {
const { barcodeScannerType } = this.state;
this.reader.stopStreams();
if (barcodeScannerType == 'qrCode') {
this.reader = new BrowserBarcodeReader();
this.props.onClose(true);
this.setState(
{
barcodeScannerType: 'barcode',
},
() => this._process()
);
}
};