Failed to run demo: Cannot read property 'ImageWrapper' of undefined
See original GitHub issueI’m trying to run this demo in React, but always got error:
import React, { useState, FC, useRef, useEffect, isValidElement } from "react";
import { QuaggaJSStatic } from "@ericblade/quagga2";
import QuaggaLib from "@ericblade/quagga2/lib/quagga";
let Quagga: QuaggaJSStatic = QuaggaLib;
let BarcodeArea: FC<{}> = (props) => {
let videoElementRef = useRef<HTMLDivElement>(null);
useEffect(() => {
Quagga.init(
{
inputStream: {
type: "LiveStream",
target: videoElementRef.current,
constraints: {
width: 400,
height: 400,
},
},
locate: false,
numOfWorkers: 2,
frequency: 10,
decoder: {
readers: ["code_128_reader"],
},
},
(err) => {
if (err) {
console.error(err);
return;
}
console.log("started");
Quagga.start();
}
);
Quagga.onDetected((result) => {
console.log("detect", result);
});
Quagga.onProcessed((result) => {
console.log("process", result);
});
return () => {
Quagga.stop();
};
}, []);
return <div className={styleVideo} ref={videoElementRef}></div>;
};
Also I tried to run the demo at http://localhost:8080/example/live_w_locator.html by fixing the paths and adding Quagga = quagga.default
. Turned out the problem remains.
Is there a fix for that?
Issue Analytics
- State:
- Created 4 years ago
- Comments:21 (10 by maintainers)
Top Results From Across the Web
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >React - TypeError: Cannot read property 'img' of undefined
The main issue is how you compute a random card, you are indexing out of the array. const randCard = cards[Math.floor(Math.random() ...
Read more >How to Prevent the Error: Cannot Read Property '0' of Undefined
A guide on how to prevent the error "cannot Read Property '0' of Undefined", covering techniques such as try, catch, using const over...
Read more >Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError : Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an...
Read more >Cannot read properties of undefined (reading 'id') - TrackJS
We'll often run into errors like “Cannot read properties of undefined ... TypeError is a subset of JavaScript Error that is thrown when...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i’m not convinced that with the current structure of the worker, that there’s even any benefit to it – it just ran multiple copies of itself configured the same way, across multiple threads. A restructuring of it might perhaps run different decoders on different worker threads.
I’ve published 0.0.13, if you want to try that and see if it fixes the issue. I’m going to close this one anyway, in favor of the all-encompassing “restructuring things is really needed”, but if this persists, lmk… i didn’t see it in my quick test (i did look at the console output this time 😄 )
figured it out, it’s the removal of the webpack-plugins\umd.js file that was removed as part of the upgrade to webpack from v2 to v5. i… don’t think that can be directly put back in, but i think we’ll need to study it. it would put the entire source of the quagga.js module into the factorySource variable … and that no longer exists…
maybe it can just be put back in… not sure…
… probably explains why the workers break when trying to add new readers to them, too…