react-infinite-scroller: load more function is not getting invoked!

Load More function is not getting invoked when scroll to down *Expected to see “loaded!”’ two three times but not, please help me screenshot from 2018-10-16 15-11-00

       loadMoreBooks = async () => {
         console.log('loaded!');
         const data = await db.collection('books').get();
         let books = this.state.books;
         data.forEach(book => {
           books = [...books, { id: book.id, ...book.data() }];
         });
         this.setState({ books });
      };

     // Render Method
          <InfiniteScroll
            pageStart={0}
            loadMore={this.loadMoreBooks}
            hasMore={hasMoreBooks}
            loader={
              <div className="loader" key={0}>
                Loading ...
              </div>
            }
          >
            <Tiles maxCount={4}>{bookList}</Tiles>
          </InfiniteScroll>

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 2
  • Comments: 19

Most upvoted comments

I found the point.

  1. if your scroll area not window, userWindow={false}
  2. make sure the InfiniteScroll tag directly wrap the scroll area like that <InfiniteScroll><YourScrollDiv> other children ... </YourScrollDiv></InfiniteScroll>

If any upper element has ‘overflow: auto;’ defined, it means that scroll area is not window anymore:

  1. userWindow={false}
  2. define getScrollParent function to return ‘scroll area’ dom element

<InfiniteScroll ... getScrollParent={()=>document.getElementById('el-which-has-overflow-defined')} useWindow={false}>

It’s the same here

@andrelmlins let me know if you solved somehow

Have the same issue on v1.2.4

For a temporary fix while they figure that out I went from "react-infinite-scroller": "^1.2.2" to "react-infinite-scroller": "^1.2.1" and then it started working again.