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.

Support loading more items when doing infinite scrolling

See original GitHub issue

The scenario is basically: You have X number of items and when you reach the end of the list you either: (a) show a “Load more items” button / row / element when they reach the end of the list, and show a spinner when it’s pressed, or (b) you automatically show a spinner when they reach the end of the list. Once new items show up, you continue scrolling.

I’m not sure of what the ideal API would be, but thinking about the states that need to be tracked, (disregarding the property names) I think the most flexible lower level API would need to provide something like:

  • hasMoreItems {boolean} flag to decide if it should do anything when the end of the list is reached
  • autoLoadItems {boolean} (ignored if hasMoreItems is false) flag to decide what to do when the end of the list is reached: (true) automatically trigger an action, or (false) render a “Load more items” button / row / element
  • onInfiniteLoad {() => void} (ignored if hasMoreItems is false) Called when you click on “Load more items” with false autoLoadMoreItems, or if you reach the end of the list with true autoLoadMoreItems
  • isInfiniteLoading {boolean} (ignored if hasMoreItems is false) flag to decide if it should show a spinner or the “Load more items” button / row / element
  • getLoadMoreItemElement {({ isInfiniteLoading: boolean, onInfiniteLoad: function }) => ?ReactElement} (ignored if hasMoreItems is false, return value ignored when autoLoadItems is true) get the element to render when loading (e.g. spinner) or when showing “Load more items” button / row / element
  • loadMoreItemsElementHeight {number} (ignored if hasMoreItems is false) height for the return value of getLoadMoreItemElement

Thoughts?

It could probably be taken further by supporting bi-directional infinite scrolling (e.g. you get dropped in the middle of a list and you can follow the cursors up or down the list), which means you could throw away items after a certain count in order to limit memory usage. Although, I don’t know how useful or practical that would be.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
bvaughncommented, Jan 11, 2016

This feature is available in 3.1.0

0reactions
bvaughncommented, Jan 11, 2016

FYI for anyone interested, I’ve got PR #51 up with the new InfiniteLoader component. Need to write a few more tests and stuff but I think it’s nearly ready for release. Feel free to weigh-in on the API if you’d like (although preferably before a release has been made) 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Infinite Scrolling, Pagination Or “Load More” Buttons ...
“Load more” allows the user to compare more easily products across an entire list.
Read more >
Infinite scroll vs load more button: which is better? | Publift
Infinite scroll uses lazy loading and executes its demand to load more data (products or content) at the bottom of the page, without...
Read more >
A guide to pagination, load more buttons, and infinite scroll
Here, we explain a few methods of setting up pagination, load more buttons, and infinite scroll to create more dynamic web pages.
Read more >
Pagination vs. Infinite Scroll vs. Load More Explained
Uploading new items to the current page by clicking on the button creates the effect of endless scrolling and increases user engagement. And...
Read more >
Infinite Scrolling: When to Use It, When to Avoid It
For some, pagination or a Load More button will be a better solution. ... Nike is using infinite scroll to display its products...
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