Mahamudul Hasan Rubel
HomeAboutProjectsSkillsExperienceBlogCoursesPhotosContact
Mahamudul Hasan Rubel

Senior Software Engineer crafting high-performance web applications and SaaS platforms.

Navigation

  • Home
  • About
  • Projects
  • Skills
  • Experience
  • Blog
  • Courses
  • Photos
  • Contact

Get in Touch

Available for senior/lead roles and consulting.

bd.mhrubel@gmail.comHire Me

© 2026 Mahamudul Hasan Rubel. All rights reserved.

Built with using Next.js 16 & Tailwind v4

Back to Blog
Lesson 11 of the React Fundamentals: Build Modern UIs from Scratch course
ReactReactJune 25, 20264 min read

Rendering Lists of Data in React: A Practical Guide

Learn how to use the map method for list rendering in React. Master the key prop to keep your dynamic movie lists efficient, performant, and bug-free.

Reactlist renderingmap methodkey propfrontend developmentjavascriptfrontend

Previously in this course, we explored Conditional Rendering to show or hide UI elements based on logic. Now that we can control what displays, we need to handle how much displays. In a real-world movie browser, you won't hard-code every movie card; you’ll fetch a list and render it dynamically.

Why List Rendering Matters

In modern web development, data rarely comes in static chunks. Whether it's a list of movie titles, search results, or user comments, your UI must adapt to the size of your data array. Instead of manually writing a <MovieCard /> component ten times, we use JavaScript’s built-in array methods to generate our UI programmatically.

The Map Method: Your Best Friend

In React, the standard way to transform an array of data into a list of components is the map() method. Unlike a for loop, map() returns a new array, which React can then render directly into the JSX.

When you use map(), you iterate over each object in your data array and return a React component for every item.

JSX
const movies = [
  { id: 1, title: CE9178">'Inception' },
  { id: 2, title: CE9178">'The Matrix' },
  { id: 3, title: CE9178">'Interstellar' }
];

function MovieList() {
  return (
    <ul>
      {movies.map((movie) => (
        <li key={movie.id}>{movie.title}</li>
      ))}
    </ul>
  );
}

The Importance of the Key Prop

You might notice the key={movie.id} attribute in the example above. This is not optional. React uses the key prop to identify which items in a list have changed, been added, or been removed.

Without a stable, unique key, React struggles to track component identity during updates. This can lead to performance degradation or, worse, visual bugs where the wrong data appears in the wrong list item. We’ll dive deeper into how React Reconciliation: Why Keys Are Critical for List Rendering works in the next lesson, but for now, remember: always use a unique ID from your data as the key.

Worked Example: Rendering the Movie Browser

Let's advance our movie-browser project. Instead of static cards, we will map over an array of movie objects to populate our dashboard.

JSX
const movies = [
  { id: CE9178">'m1', title: CE9178">'The Shawshank Redemption', year: 1994 },
  { id: CE9178">'m2', title: CE9178">'The Godfather', year: 1972 },
  { id: CE9178">'m3', title: CE9178">'The Dark Knight', year: 2008 },
];

function MovieDashboard() {
  return (
    <div className="movie-grid">
      {movies.map((movie) => (
        <MovieCard 
          key={movie.id} 
          title={movie.title} 
          year={movie.year} 
        />
      ))}
    </div>
  );
}

By passing movie.id to the key prop and the movie details to our component props, we create a clean, scalable structure. As discussed in our lesson on React rendering: Tracing Prop Changes from Update to DOM Patch, this declarative approach ensures that whenever the movies array changes, React knows exactly which specific DOM nodes to patch.

Hands-on Exercise

  1. Create a new array of 5 movie objects in your App.js (or a data file). Each object should have an id, title, and rating.
  2. Use the map() method to render a list of MovieCard components.
  3. Ensure each MovieCard receives the title and rating as props.
  4. Add the key prop to the MovieCard instances using the unique id from your data.

Common Pitfalls

  • Using the Index as a Key: It’s tempting to use (movie, index) => <li key={index}>. Avoid this! If the list is reordered, filtered, or items are added/removed, the index changes. This causes React to lose track of the component state, leading to subtle bugs.
  • Missing Keys: If you forget the key prop, React will throw a warning in your browser console. It will still render, but it will be inefficient and prone to errors.
  • Mapping inside the Return: Remember that map() is a JavaScript expression. It must be wrapped in curly braces {} inside your JSX to be evaluated correctly.

Recap

We've moved from static components to dynamic UI generation. By using the map() method, we can handle data of any length, and by providing a unique key prop, we ensure that React’s reconciliation engine keeps our interface fast and reliable. Mastering these patterns is essential for any React Key Prop and Component Remounting: A Practical Guide scenario you might encounter later.

Up next: The Key Prop Explained — why exactly React gets confused when keys are missing or non-unique.

Previous lessonConditional RenderingNext lesson The Key Prop Explained
Back to Blog

Similar Posts

ReactReactJune 25, 20263 min read

Fetching Data from an API: A Practical React Guide

Master the fetch API in React to retrieve external data. Learn to perform asynchronous requests and store JSON responses in your component state effectively.

Read more
ReactReactJune 25, 20263 min read

Part of the course

React Fundamentals: Build Modern UIs from Scratch

beginner · Lesson 11 of 49

  1. 1

    Introduction to Component-Based Architecture

    4 min
  2. 2

    Understanding the Virtual DOM

    4 min
  3. 3

    Setting Up with Vite

    3 min

Building a Movie Filter Toggle in React: A Beginner's Guide

Master the art of UI state management by adding a filter toggle to your movie app. Learn to control list rendering using boolean state and checkbox inputs.

Read more
ReactJune 25, 20263 min read

Prop Drilling and Context API: Simplifying React State Sharing

Learn to stop prop drilling in your React applications. Discover how the Context API lets you share data globally without manual prop passing.

Read more
4

Mastering JSX Syntax

4 min
  • 5

    Creating Static Components

    3 min
  • 6

    Styling Components

    3 min
  • 7

    Passing Data with Props

    3 min
  • 8

    Dynamic Movie Cards

    3 min
  • 9

    Component Composition

    3 min
  • 10

    Conditional Rendering

    3 min
  • 11

    Rendering Lists of Data

    4 min
  • 12

    The Key Prop Explained

    4 min
  • 13

    Introduction to React State

    4 min
  • 14

    Managing State with useState

    3 min
  • 15

    Building an Interactive Search Bar

    3 min
  • 16

    Handling Click Events

    4 min
  • 17

    Updating State Based on Previous State

    4 min
  • 18

    Filtering the Movie List

    3 min
  • 19

    Handling Form Submissions

    3 min
  • 20

    Controlled Components

    4 min
  • 21

    Event Bubbling and Propagation

    3 min
  • 22

    Building a Movie Filter Toggle

    3 min
  • 23

    Introduction to Side Effects

    4 min
  • 24

    useEffect Dependencies

    4 min
  • 25

    Fetching Data from an API

    3 min
  • 26

    Handling Loading States

    3 min
  • 27

    Managing Errors

    3 min
  • 28

    Cleanup Functions in useEffect

    3 min
  • 29

    Debouncing Search Input

    3 min
  • 30

    Refactoring for Clean Code

    3 min
  • 31

    Folder Structure Best Practices

    4 min
  • 32

    Extracting Custom Hooks

    3 min
  • 33

    Prop Drilling and Context API

    3 min
  • 34

    Polishing the UI

    Coming soon
  • 35

    Finalizing the Movie Browser

    Coming soon
  • 36

    Review of Component Lifecycle

    Coming soon
  • 37

    Review of State Management

    Coming soon
  • 38

    Building a Modal Component

    Coming soon
  • 39

    Introduction to PropTypes

    Coming soon
  • 40

    Performance Optimization Basics

    Coming soon
  • 41

    Handling Browser History

    Coming soon
  • 42

    Working with LocalStorage

    Coming soon
  • 43

    Building a Favorites List

    Coming soon
  • 44

    Handling Media in React

    Coming soon
  • 45

    Introduction to Testing

    Coming soon
  • 46

    Debugging React Apps

    Coming soon
  • 47

    Deployment Basics

    Coming soon
  • 48

    Using External Libraries

    Coming soon
  • 49

    Advanced

    Coming soon
  • View full course