Skip to content

List Rendering

In one line

List rendering means transforming an array of data into an array of JSX elements using the .map() method.

In simple words

To render a list of items in React, you take your data array and call .map() to transform each data item into a JSX element. React renders each element in the resulting array.

Every item in a list must have a unique key prop. Keys help React identify which items changed, were added, or were removed, enabling efficient reconciliation. Use a stable unique ID from your data as the key — avoid using array indices as keys if the list can be reordered or items can be inserted/removed, because that causes subtle bugs.

map() returns a new array, which React renders as a fragment of siblings. You can also use filter() before map() to render only matching items.

Example

jsx
const fruits = [
  { id: 1, name: "Apple" },
  { id: 2, name: "Banana" },
  { id: 3, name: "Cherry" },
];

function FruitList() {
  return (
    <ul>
      {fruits.map(fruit => (
        <li key={fruit.id}>{fruit.name}</li>
      ))}
    </ul>
  );
}

map transforms each fruit object into an <li>. The key prop uses the unique id so React can track items across re-renders.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary