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.

React-infinite fails with `Cannot read property 'scrollShouldBeIgnored' of undefined`

See original GitHub issue

Hi @developit! I was checking some functionality which is based on https://github.com/seatgeek/react-infinite. I wasn’t able to check if onLoad triggers because it throws an error while scrolling. It’s reproducible with preact@5.1.0-beta.26 as well as preact@5.3.0:

import Infinite from 'react-infinite'

export default class TestInfinite extends React.Component {
    onLoad = () => {
        console.log('`onLoad` should be triggered')
    }

    render() {
        const height = 300
        const offset = 100

        return (
            <Infinite
                containerHeight={height - offset}
                elementHeight={height}
                infiniteLoadBeginEdgeOffset={offset}
                onInfiniteLoad={this.onLoad}>
                    <div style={{height}}>content</div>
            </Infinite>
        )
    }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:32 (23 by maintainers)

github_iconTop GitHub Comments

2reactions
developitcommented, Nov 14, 2016

Turns out this was actually ridiculously easy - createClass binds methods you pass to it, but it was binding them after invoking the constructor, which was where react-infinite grabs its reference to the event handler in question - meaning it had a reference to the unbound function instead of the bound one. Simple fix was just to bind earlier. Your repro is now working for me locally @slmgc ❤️

The fix is released as preact-compat@3.9.2.

1reaction
developitcommented, Nov 14, 2016

yay! 7.0 will become mainline shortly, it’s just in beta as the group of (technically) breaking changes gets solidified.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error in ajax(can't read property of undefined) while ...
I am trying to implement infinite scroll in react js by repeating the same set of data a certain number of times and...
Read more >
Cannot read property 'getBoundingClientRect' of null · Issue ...
Following the 'full example' I get this error once I scroll while the component where react-simple-infinite-scroll lies has been unmount.
Read more >
How to Read React Errors (fix 'Cannot read property of ...
Got an error like this in your React component? Cannot read property `map` of undefined. In this post we'll talk about how to...
Read more >
What is "TypeError: Cannot read property 'state' of undefined"?
The error message says that you don't have the state property on an undefined object. ... We get “TypeError: Cannot read property 'sound'...
Read more >
Cannot read property of undefined? Weird : r/reactjs - Reddit
So, when calling an API, I'm getting an error that it can't read property "en" of undefined. Here is the code:
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