← React Foundations
4 / 25
Lesson 4 — Rendering lists
Turn arrays into elements
To show a list, map the array to JSX: each item becomes an element. React needs a key prop on each one — a value unique among its siblings — so it can tell items apart when the list changes.
const colors = ["red", "blue"];
<ul>{colors.map((c) => <li key={c}>{c}</li>)}</ul>
Why it matters: search results, chat messages and shopping carts are all arrays rendered this way.
Want it another way?
Task
Add "Ship" to items and render every item as an <li>. The preview should show a 3-item list: Learn, Build, Ship.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.