Skip to content
This repository has been archived by the owner on Nov 8, 2020. It is now read-only.

Infinte Loading: Basic implementation #14

Merged
merged 13 commits into from
Aug 23, 2018
Merged

Conversation

dmitriy-kudelko
Copy link
Collaborator

@dmitriy-kudelko dmitriy-kudelko commented Aug 23, 2018

This adds basic implementation of infinite loading functionality. We might want to improve the logic to determine when loadMoreRows callback should be invoked. But for now let's proceed with this naive implementation.

Copy link
Owner

@samrith-s samrith-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmitriy-kudelko A couple of comments below.

Additionally:

  • Can we also ensure that there are dependent props checks? Like for example for infinite loading, all props need to be given by the user or we throw an error, rather than silently failing it.
  • Can we provide a default loader? Coz right now, it just renders empty cells.
  • Why are we adding multiple rows at the bottom? Shouldn't we rather add just 1 row and let the user customize if they want to add multiple rows?

@@ -260,37 +272,64 @@ export default class Table extends PureComponent {
checkboxRenderer,
idKey,
rowClassName,
rowRenderer: renderer
rowRenderer: renderer,
loadMoreLoaderRowCount,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have way too many loadMore-X props. Can we rename them to something more meaningful or create an infiniteLoading prop which is an object and accepts customizations? This seems ugly.

Copy link
Collaborator Author

@dmitriy-kudelko dmitriy-kudelko Aug 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my eyes grouping props in an object is a worse stuff because it leads to wasted re-renders since you provide a new object literal each time. This is why they are all namespaced with loadMore. We can use infiniteLoading instead. It's just way longer.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, that makes sense. Let's keep this for now.

Another thing, why are we asking for a loadMoreTotalCount? We are assuming we will have a finite list. In case of something like a Twitter timeline, there could be tweets tending to infinity. In that case, it might not always be possible to pass a loadMoreTotalCount.

I think in the table, we would be better off just firing the loadMore call whenever the scroll reaches bottom, and let the user handle it in their callback.

What say?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are assuming we will have a finite list.

So here I followed existing use cases of how we use react-virtualized infinite loader on Email Logs/Campaigns pages where we exactly know the total number of rows in the database. In fact this is how most of infinite loaders implemented (including react virtualized InfiniteLoader)

isChecked,
rowIndex,
renderer,
loadMoreCellRenderer,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, can we use a better name than loadMore-X?

@dmitriy-kudelko
Copy link
Collaborator Author

@samrith-s regarding the main review comment...

  1. Yes, I think it's a good idea, but we should not throw an error I think. Displaying a warning is enough.
  2. It's also a good idea. Do you have some loader in your mind we could add as a dependency?
  3. I followed our practice to display 5 additional rows as on Email Logs/Campaigns pages. We can change the default setting to 1. Not a big deal.

@samrith-s
Copy link
Owner

@dmitriy-kudelko

  1. I think we should throw an error, otherwise we are handling a lot of stuff which is technically outside the scope of the table.
  2. We can use a simple loader from here http://www.davidhu.io/react-spinners/
  3. I think we should change the default to one, or make the number of loading rows to be customizable. For now, we could just reduce it to 1.

@dmitriy-kudelko
Copy link
Collaborator Author

@samrith-s , please verify.

Copy link
Owner

@samrith-s samrith-s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmitriy-kudelko Everything looks good!

Regarding this comment #14 (comment), I'll create a separate issue for it. We can pick it up later.

@samrith-s samrith-s merged commit 9559969 into master Aug 23, 2018
@samrith-s samrith-s deleted the feature/infinite-scroll branch August 23, 2018 16:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants