dependabot[bot] on npm_and_yarn
build(deps): bump json5 from 1.… (compare)
File "<PATH>/@ericblade/quagga2/type-definitions/quagga.d.ts" is not a module
when I try to import it. I know I could just add // @ts-ignore
and get on with it, but I would really like to have type-support, so if anybody knows what might be wrong give me a shout! :)
@ericblade hmm, well I am testing on external url which is just using http. so yea that could be the reason why
This is my code for the Scanner.js
its pretty referenced from your repo. dont think i did anything wrong here
import React from 'react';
import Quagga from 'quagga';
import PropTypes from 'prop-types';
class Scanner extends React.Component {
constructor(props) {
super(props);
this.onDetected = this.onDetected.bind(this);
}
componentDidMount() {
Quagga.init(
{
inputStream: {
type: 'LiveStream',
constraints: {
width: 640,
height: 480,
facingMode: 'environment', // or user
},
},
locator: {
patchSize: 'medium',
halfSample: true,
},
numOfWorkers: 1,
decoder: {
readers: ['ean_reader'],
},
locate: true,
},
function(err) {
if (err) {
return console.log(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 id="interactive" className="viewport" />;
}
}
Scanner.propTypes = {
onDetected: PropTypes.func.isRequired,
};
export default Scanner;
but let try change the external url to https and see if thats the problem
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.