Untitled
unknown
javascript
2 years ago
467 B
11
Indexable
const finalList = products
.filter(el => (
el.name.toLowerCase().includes(filterText.toLowerCase()) &&
(inStockOnly ? el.stocked : true)
))
.reduce((a, c) => {
if (c.category !== a.lastCategory) {
a.output.push(<ProductCategoryRow key={c.category} category={c.category} />);
a.lastCategory = c.category;
}
a.output.push(<ProductRow key={c.name} product={c} />);
return a;
}, { lastCategory: null, output: [] });Editor is loading...
Leave a Comment