hey guys,
so this is my current configuration for the product scanner in React
import React from 'react';
import Quagga from 'quagga';
import PropTypes from 'prop-types';
class ProductScanner extends React.Component {
constructor(props) {
super(props);
this.onDetected = this.onDetected.bind(this);
}
componentDidMount() {
Quagga.init(
{
inputStream: {
name: 'Live',
type: 'LiveStream',
target: document.querySelector('#interactive'),
constraints: {
width: 640,
height: 480,
facingMode: 'environment', // or user
},
},
locator: {
patchSize: 'medium',
halfSample: true,
},
numOfWorkers: 1,
decoder: {
readers: this.props.decoderReaders,
},
locate: true,
},
function(err) {
if (err) {
return err;
}
return Quagga.start();
},
);
Quagga.onDetected(this.onDetected);
}
componentWillUnmount() {
Quagga.offDetected(this.onDetected);
Quagga.stop();
}
onDetected(result) {
const drawingCanvas = Quagga.canvas.dom.overlay;
drawingCanvas.style.display = 'none';
this.props.onDetected(result);
}
render() {
return <div className={this.props.className} id="interactive" />;
}
}
ProductScanner.propTypes = {
className: PropTypes.string,
onDetected: PropTypes.func.isRequired,
decoderReaders: PropTypes.array.isRequired,
};
ProductScanner.defaultProps = {
className: '',
};
export default ProductScanner;
the ProductScanner component accepts any decoder s in the form of an array
the current value for the prop decoderReaders is ['code_39_reader']
as that is the types of barcodes we read for our online store
This configuration works locally but on our live site, the we get this error
Uncaught ReferenceError: yca is not defined
webpack
compatitablity with regards to minification
hey @jimsmits19 sorry i haven't been around here the last .. several.. days. have been busy elsewhere :-)
Sure, code and samples help. Might be helpful to know what sort of hardware you're trying to use with, as well, I've been completely unable to get, for example, my PC's webcam to recognize anything at all, no matter what settings I try to use. My laptop occasionally has results. But for the most part, I only really have success with a cell camera.