Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

map in react

const array={{firstName:"x", lastName:"y"},{firstName:"a", lastName:"b"}}

// Method 1: Without using "{}"
array.map((item)=>(
  <ComponentName fName={item.firstName} lName={item.lastName} />
));

// Method 2: With using "{}"
array.map((item)=>{
  return(<ComponentName fName={item.firstName} lName={item.lastName} />)
});
Source by reactjs.org #
 
PREVIOUS NEXT
Tagged: #map #react
ADD COMMENT
Topic
Name
2+9 =