Untitled

mail@pastecode.io avatar
unknown
javascript
2 months ago
467 B
3
Indexable
Never
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: [] });
Leave a Comment