sforkowany z mirror/soapbox
ScrollableList: don't call onLoadMore() unless it hasMore
rodzic
c4f7106b77
commit
bcb8d75f71
|
@ -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={{
|
||||||
|
|
Ładowanie…
Reference in New Issue