Learn how to render lists, filter data, and work with arrays in React!
Min Age: 20
Grade: A
Subject: Computer Science
Max Budget: $500
Category: Electronics
Stock: In Stock Only
Students: 1/5
Products: 0/5
High Priority Todos: 3
Age: 20
Grade: A
Computer Science
No products match your criteria. Try increasing your budget or changing the category!
Due: 2024-01-15
Due: 2024-01-20
Due: 2024-01-25
Priority: high
Priority: low
{students.map((student) => (
<div key={student.id}>
<h3>{student.name}</h3>
<p>Age: {student.age}</p>
</div>
))}Use .map() to transform array items into JSX. Always provide a unique key!
const filteredStudents = students.filter(student =>
student.age >= 20 &&
student.grade === "A"
);
{filteredStudents.map(student => ...)}Filter arrays first, then render. This creates new arrays without modifying originals.
<div className={`p-4 rounded ${
product.inStock
? "border-green-200 bg-green-50"
: "border-red-200 bg-red-50"
}`}>
{product.name}
</div>Use conditional logic inside map() to style items differently based on their data.
minAge to 21 and see fewer studentsmaxBudget to 100 - watch products disappear!targetGrade = "B" to see different studentsselectedCategory to "Furniture"showOnlyInStock = false