React MapFunction:
The Map function creates a new array by performing a function on each array element. The map function does not execute the function for array elements without values. The map function does not change the original array.
code:
import React from "react";
class MapFunction extends React.Component{
constructor(props){
super(props);
this.state={
fruitesName:["Apple","Banana","Orange","Graphs"]
}
}
render(){
return<div>
<ul>
{this.state.fruitesName.map((fruit, index) => (
<li key={index}>{fruit}</li>
))}
</ul>
</div>
}
}
export default MapFunction;
No comments:
Post a Comment