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.

Cannot set property 'settings' of undefined

See original GitHub issue

I use jquery-lazyload 1.9.7 with reactjs, it works well. I try to use lazyload 2.0.0-beta.2 with reactjs, I got errors like

Uncaught (in promise) TypeError: Cannot set property 'settings' of undefined
    at LazyLoad (lazyload.js:78)

my react component call lazyload like

  componentDidMount() {
    const images = this.node.querySelectorAll('.lazyload')
    lazyload(images, {
      threshold: 200,
    })
  }

I think it should be a bug.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:11

github_iconTop GitHub Comments

6reactions
cYang2030commented, Sep 26, 2019

Do not use lazyload() instead of new lazyload()

4reactions
pherrymasoncommented, Dec 10, 2017

I had the same problem and it was because I was not calling properly Lazyload. Initially I was doing this:

var lazyload = require('lazyload.js');
lazyload();

But, what I should do is:

var lazyload = require('lazyload.js');
var obj = new lazyload();
Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript - cannot set property of undefined - Stack Overflow
d[a] == undefined , so you're doing undefined['greeting']=b; and by definition, undefined has no properties. Thus, the error you received. Share.
Read more >
Uncaught TypeError: Cannot set property
In JavaScript if a variable has been declared, but has not been assigned a value, is automatically assigned the value undefined . Therefore,...
Read more >
How to solve the 'cannot set property of undefined' issue on ...
To access an object key the object has to exist. When it doesn't and you try to access the key, you get the...
Read more >
jQuery - Cannot read property 'settings' of undefined - YouTube
jQuery : JQuery Validate Uncaught TypeError: Cannot read property ' settings' of undefined [ Beautify Your Computer ...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
The TypeError: Cannot read property of undefined is one of the most common type errors in JavaScript. It occurs when a property is...
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