React js map function example with rendering arrays

04-Apr-2023

.

Admin

Hello Friends,

In react map function use for print array. also you can use map function in render return method. if you have question How to render dynamic elements in react follow this tutorial. map function also use for print nested array. in this blog let me show you how to loop through an array of data using React best practices.

Following component provide demo of reactjs array map method. How to render an array of objects in React?, How to map an array of objects in React this all question answer you can get here...

/src/MapExample.js


import React from 'react'

class MapExample extends React.Component{

render(){

const dummyArray = ['one', 'two', 'three', 'four', 'five'];

return(

<ul>

{dummyArray.map((value, index) => {

return <li key={index}>{value}</li>

})}

</ul>

)

}

}

export default MapExample;

I hope it can help you...

#React.js