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