ListOverlay: don't loop through all items if we just want 2
`map` does not short-circuit
This commit is contained in:
parent
5b2c901496
commit
2e3f9f94ce
1 changed files with 7 additions and 10 deletions
|
@ -25,20 +25,17 @@ function CollectionPreviewOverlay(props: Props) {
|
|||
}, [collectionId, collectionItemUrls, fetchCollectionItems]);
|
||||
|
||||
if (collectionItemUrls && collectionItemUrls.length > 0) {
|
||||
const displayed = collectionItemUrls.slice(0, 2);
|
||||
|
||||
return (
|
||||
<div className="collection-preview__overlay-thumbs">
|
||||
<div className="collection-preview__overlay-side" />
|
||||
<div className="collection-preview__overlay-grid">
|
||||
{collectionItemUrls &&
|
||||
collectionItemUrls.map((item, index) => {
|
||||
if (index < 2) {
|
||||
return (
|
||||
<div className="collection-preview__overlay-grid-items" key={item}>
|
||||
<FileThumbnail uri={item} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
})}
|
||||
{displayed.map((uri) => (
|
||||
<div className="collection-preview__overlay-grid-items" key={uri}>
|
||||
<FileThumbnail uri={uri} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue