ScrollableList: don't call onLoadMore() unless it hasMore
This commit is contained in:
parent
c4f7106b77
commit
bcb8d75f71
1 changed files with 7 additions and 1 deletions
|
@ -104,6 +104,12 @@ const ScrollableList: React.FC<IScrollableList> = ({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleEndReached = () => {
|
||||||
|
if (hasMore && onLoadMore) {
|
||||||
|
onLoadMore();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Render the actual Virtuoso list */
|
/** Render the actual Virtuoso list */
|
||||||
const renderFeed = (): JSX.Element => (
|
const renderFeed = (): JSX.Element => (
|
||||||
<Virtuoso
|
<Virtuoso
|
||||||
|
@ -111,7 +117,7 @@ const ScrollableList: React.FC<IScrollableList> = ({
|
||||||
className={className}
|
className={className}
|
||||||
data={data}
|
data={data}
|
||||||
startReached={onScrollToTop}
|
startReached={onScrollToTop}
|
||||||
endReached={onLoadMore}
|
endReached={handleEndReached}
|
||||||
isScrolling={isScrolling => isScrolling && onScroll && onScroll()}
|
isScrolling={isScrolling => isScrolling && onScroll && onScroll()}
|
||||||
itemContent={renderItem}
|
itemContent={renderItem}
|
||||||
context={{
|
context={{
|
||||||
|
|
Loading…
Reference in a new issue