Skip to main content
D
React
React Lists and Keys

React Lists and Keys

React renders lists of data dynamically using arrays.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

When developers have an array of data, like ten different blog posts, they don't write the HTML ten times. Instead, they use the JavaScript `map()` method to loop through the array and render a component for every single item automatically.

Example

Example
1/* this renders a list */
2function CarList({ cars }) {
3  return (
4    <ul>
5      {cars.map((car) => (
6        <li key={car.id}>{car.name}</li>
7      ))}
8    </ul>
9  );
10}

Key Points

  • The `map()` method loops over an array of data.
  • Every item in a list must have a unique `key` prop.
  • The `key` helps React update the list efficiently.
  • Do not use the array index as a key if the list can change.

Up Next

Continue your journey with the next topic.

Go to React Forms