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