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