question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Renderer is not a constructor"

See original GitHub issue

This is not a direct issue for us, but to help you improve your code, I thought I’d share something I found. We are getting the Exception “i is not a constructor”. You can safely catch and ignore the exception, and everything seems to work fine, but it is still there.

My code now is the following:

try {
    JsBarcode(imgID, barValue, {format:barFormat, displayValue:showValue, fontSize:parseInt(barFont), width:parseInt(barWidth), height:parseInt(barHeight), ratio:0.8});
} catch (err) {
    jslog("Error when using JsBarcode: " + err.message);
    //There is an error in JsBarcode we need to ignore (ie: i is not a constructor)
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:25 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
lindellcommented, Sep 2, 2016

That is absolutely the reason! I know to not loop over array with for in but sometimes you do the simplest thing you know are going to work (on your machine).

I will patch the issue sometime this weekend.

Thanks very much for the assistance!

2reactions
rmachielsecommented, Sep 2, 2016

@lindell I think I know what is causing the problem. I couldn’t get the issue reproduced in a codepen snippet or something, so I started to do some digging myself.

I discovered that the are some places where you iterate over an array using a for loop. That would be a normal thing in plain javascript, however in my case, I am using this library inside an Ember.js project. Ember.js extends the prototype of Array with a lot of extra functions, somehow causing extra keys.

In a plain javascript console, iterating over array keys looks like this:

schermafbeelding 2016-09-02 om 17 16 01

However, in an Ember.js project, it looks like this:

schermafbeelding 2016-09-02 om 17 15 51

Finally, this causes this location in your project to fail:

schermafbeelding 2016-09-02 om 17 15 34

That also explains why the barcode is still rendered (on the first iteration) and why it is rendering more then once (for each key).

Probably the other people that are having this problem are also using a library that manipulates the array prototype. This is probably an example of why prototype extensions are a bad idea haha. However, this could be fixed by using something like this to iterate (in es6):

this._renderProperties.forEach((renderProperties) => {
  render(renderProperties, ...);
});

So, here is a codepen example that does reproduce the issue: http://codepen.io/anon/pen/EgxLBB

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: "x" is not a constructor - JavaScript - MDN Web Docs
The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor,...
Read more >
Uncaught TypeError: Renderer is not a constructor - Odoo
Hello, I am trying to display two form view of differernt model on same window.example one form is survey_form of survey.survey and second ......
Read more >
THREE.WEBGLRenderer is not a constructor error in three js
Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
Read more >
WebGLRenderer – three.js docs
The WebGL renderer displays your beautifully crafted scenes using WebGL. ... This is automatically created by the renderer in the constructor (if not...
Read more >
Your First three.js Scene: Hello, Cube!
Last but not least, there's a visible object such as a mesh. ... The constructor for the renderer does take several parameters, however,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found