Untitled
const finalList = products .filter((product) => product.name.toLowerCase().includes(filterText.toLowerCase()) && (product.stocked || !inStockOnly) ) .reduce((a, c) => { const categoryRow = c.category !== a.lastCategory ? [<ProductCategoryRow key={c.category} category={c.category} />] : []; return { lastCategory: c.category, output: [...a.output, ...categoryRow, <ProductRow key={c.name} product={c} />] }; }, { lastCategory: null, output: [] });
Leave a Comment