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