hasMore is true, but loadMore only gets called twice
See original GitHub issueEven 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:
- Created 2 years ago
- Reactions:3
- Comments:16
Top 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 >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
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 bedataLength={items.length}
…TBH I am not sure why the component needs
dataLength
given it useshasMore
to know if there’s more to render, and it could presumably usechildren.length
to know how many elements are displayed. 🤷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.