VOOZH about

URL: https://www.geeksforgeeks.org/reactjs/different-ways-to-render-a-list-of-items-in-react/

⇱ Different Ways To Render a List of Items in React - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Different Ways To Render a List of Items in React

Last Updated : 7 Aug, 2025

In React, when we are working with dynamic data, it is common to render a list of items. In React, there are several methods to render the list efficiently.

👁 ways_to_render_a_list
Ways to render a list

1. Using Array.map()

Array.map() is a built-in JavaScript function provided by JavaScript. It iterates over the list of items in the array and returns a list of React components

  • map() function is called over the array, and a callback function is accepted as an argument
  • callback function will take the item and index as arguments
  • index should be used as a key for the item

To start the application run the following command.

npm start

Output

👁 Screenshot-2024-03-07-144416
OUTPUT IMAGE OF Array.map() FUNCTION

2. Using for loop

for loop is a control flow statement in JavaScript. It is used to iterate over the items in a array. In this iterator or loop variable will be used to access the array elements.

Output

👁 Screenshot-2024-03-07-144816
OUTPUT IMAGE - FOR LOOP

3. Using Array.forEach()

  • forEach() function takes a callback function as an argument
  • That callback function will be executed for each array item
  • callback function takes item and index as argument.

Output

👁 Screenshot-2024-03-07-145041
Array.forEach() function

4. Using React.Children.map()

  1. It is a utility function in React
  2. It is used to iterate over the child component
  3. It takes a callback function as an argument
  4. The callback functions takes child and index as arguments to iterate over the child components and modify it

Output

👁 Screenshot-2024-03-07-145846
OUTPUT IMAGE - React.Children.map() Method

5. Using map() and JSX Spread Attributes

  • This method is used to render the components with dynamic props
  • In the callback function while rendering the components props will be passed to it
  • The callback function take item and index as the argument

Output:

👁 Screenshot-2024-03-07-150505
OUTPUT IMAGE FOR map() with JSX props
Comment
Article Tags: