Answers for "how map list in react"

0

map an array in react

//lets say we have an array of objects called data
<div className="sample">
  {data.map((item)=>{
    return(
  <div key={item.id} className="objectname">
    <p>{item.property1}</p>
    <p>{item.property2}</p>
  </div>
    );
  });
</div>
Posted by: Guest on December-03-2021
-1

react map list render dictionary

const obj = {
  foo: 'bar',
  baz: 42
}

console.log('Object.entries')
console.log(
  Object.entries(obj)
)

console.log('Mapping')
console.log(
  Object.entries(obj)
  .map( ([key, value]) => `My key is ${key} and my value is ${value}` )
)
Posted by: Guest on March-09-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language