Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
441 B
2
Indexable
Never
  const finalList = products.reduce( (a,c) => {
    if(c.name.toLowerCase().indexOf(filterText.toLowerCase()) === -1) {return a}
    if(inStockOnly && !c.stocked) {return a}
    (a.lastCategory !== c.category) && a.output.push(<ProductCategoryRow category={c.category} key={c.category} />)
    a.output.push(<ProductRow product={c} key={c.name} />)
    a.lastCategory = c.category
    return a
  },{ lastCategory: null, output: [] } )
Leave a Comment