Untitled
SWKP
plain_text
a year ago
620 B
4
Indexable
const myFilter = products.filter(el => { const isMatching = el.name.toLowerCase().includes(filterText.toLowerCase()); const isStockMatch = (inStockOnly && el.stocked) || (!inStockOnly); return isMatching && isStockMatch; }); const finalList = myFilter.reduce((a, c) => { const isNewCategory = c.category !== a.lastCategory; a.output = [...a.output,...(isNewCategory ? [<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