I had higher order component in react like this:
export default function (InnerComponent) {
class InfiniteScrolling extends React.Component {
co
componentDidMount() {
window.addEventListener('scroll', this.onScroll, false);
}
componentWillUnmount() {
window.removeEventListener('scroll', this.onScroll, false);
}
// use arrow function instead
onScroll = () => {
if ((window.innerHeight + window.scrollY) >= (document.body.offsetHeight - 50)) {
const { scrollFunc } = this.props;
scrollFunc();
}
}
or you can use Arrow functions , to solve .bind(this) problems it worked form just fine.