Answers for "react for"

20

map function in react

function NameList() {
	const names = ['Bruce', 'Clark', 'Diana']
    return (
    	<div>
      {names.map(name => <h2>{name}</h2>)}
      	</div>
    )
}
Posted by: Guest on October-15-2020
1

react for

render() {
  const elements = ['one', 'two', 'three'];

  const items = []

  for (const [index, value] of elements.entries()) {
    items.push(<li key={index}>{value}</li>)
  }

  return (
    <div>
      {items}
    </div>
  )
}
Posted by: Guest on May-19-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language