ScrollableList: don't call onLoadMore() unless it hasMore

This commit is contained in:
Alex Gleason 2022-04-23 16:43:37 -05:00
parent c4f7106b77
commit bcb8d75f71
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -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={{