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.

hasMore is true, but loadMore only gets called twice

See original GitHub issue

Even if hasMore is set to true (to test this I have hard set it to always be true), loadMore function gets called only twice. Has anyone seen this type of issue before?

                               <InfiniteScroll
                                dataLength={eventListCount}
                                next={this.loadMore}
                                hasMore={!isFetching && hasMore}
                                loader={<h4>Loading...</h4>}
                                height={height}
                                >
                              //  .. render component which lists data from eventList
                            </InfiniteScroll>

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:16

github_iconTop GitHub Comments

34reactions
mikelehencommented, May 23, 2021

I had the same issue. It turns out I was using dataLength wrong. I thought it was supposed to be the total length of items that could be displayed, but instead it seems it should be the length of items that are currently displayed, i.e. in @RAMKUMARDANE’s example above it should probably be dataLength={items.length}

TBH I am not sure why the component needs dataLength given it uses hasMore to know if there’s more to render, and it could presumably use children.length to know how many elements are displayed. 🤷

3reactions
sychovSaveliycommented, Jun 6, 2021

Hey, I also met it and fix for me: set to dataLength a current length of list (from state). It will a trigger for calling fetchMore. I tried set total list of data - doesn’t work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

“react-infinite-scroll-component” Stopped working after one ...
I use the react-infinite-scroll-component library for pagination,but even though hasMore is true, loadMore is called once.
Read more >
react-infinite-scroll-component” Stopped working after one call ...
Coding example for the question “react-infinite-scroll-component” Stopped working after one call (loadMore only gets called once)-Reactjs.
Read more >
React Infinite Scroll
loadMore, true, -, func, A function that will be called after reaching the ... If it's set to true, infinite scroll will calculate...
Read more >
React Hooks for infinite scroll: An advanced tutorial
Next, let's add a function that will be called each time we want to load ... useRef(false); const [hasMore, setHasMore] = useState(true); ...
Read more >
How to Handle Data Lists in React Like a Pro — FlatList React
Often enough, you get to deal with some set of data that you must list to the user. This can be in a...
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