React-infinite fails with `Cannot read property 'scrollShouldBeIgnored' of undefined`
See original GitHub issueHi @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:
- Created 7 years ago
- Comments:32 (23 by maintainers)
Top 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 >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
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 wherereact-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
.yay! 7.0 will become mainline shortly, it’s just in beta as the group of (technically) breaking changes gets solidified.