Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onBarCodeRead = ({ data }: { data: string }) => {
if (data && data !== this.lastData && !this.completed) {
this.lastData = data;
try {
this.frames = parseFramesReducer(this.frames, data);
this.setState({ progress: progressOfFrames(this.frames) });
if (areFramesComplete(this.frames)) {
try {
this.onResult(decode(framesToData(this.frames).toString()));
this.completed = true;
} catch (error) {
this.frames = null;
this.setState({ error, progress: 0 });
}
}
} catch (e) {
console.warn(e);
}
}