Untitled
user_8975601
plain_text
2 years ago
577 B
34
Indexable
const myFilter = products.filter(el => el.name.toLowerCase().includes(filterText.toLowerCase()) && (!inStockOnly || el.stocked) ); // console.log(myFilter) const finalList = myFilter.reduce((a, c) => { const isCategoryChanged = c.category !== a.lastCategory; if (isCategoryChanged) { 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: [] });
Editor is loading...
Leave a Comment