Answers for "loop object react"

6

react js iterate object

<div className="iterate-object">
{
	<ul>
  		{Object.keys(OBJECTHERE).map(function(keyName, keyIndex) {
    		return (
      			<li key={keyName}>
					{keyName}
                    {console.log(OBJECTHERE[keyName])}
          		</li>
    		)
		})}
	</ul>
}
</div>
Posted by: Guest on May-02-2020
13

react for loop in render

render: function() {
  const elements = ['one', 'two', 'three'];
  return (
    <ul>
      {elements.map((value, index) => {
        return <li key={index}>{value}</li>
      })}
    </ul>
  )
}
Posted by: Guest on January-06-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language