Lists & Dynamic Rendering
The Problem: Too Much Repetition
function ProductCatalog() {
return (
<div>
<ProductCard name="Mohinga" price={3500} stock={24} category="Breakfast" />
<ProductCard name="Shan Noodles" price={4000} stock={15} category="Lunch" />
<ProductCard name="Tea Leaf Salad" price={3000} stock={0} category="Appetizer" />
<ProductCard name="Samosa" price={1500} stock={45} category="Snack" />
<ProductCard name="Mandalay Noodles" price={3800} stock={12} category="Lunch" />
</div>
);
}The Solution: Map Over Arrays
Understanding Keys
Why Keys Matter
Key Rules
Real Example from POS System
Passing Whole Objects as Props
Filtering Lists
Multiple Filters
Sorting Lists
Nested Lists
Conditional Rendering in Lists
Empty States
Complete Example: POS Product Catalog
Key Learnings
โ
List Rendering Pattern
โ
Keys Are Required
โ
Filter Before Mapping
โ
Sort Creates New Array
โ
Always Handle Empty States
Common Mistakes I Made
Next Steps
Last updated