{array.map((item)=>{
return (
<div key={item.id}>I am one Object in the Array {item}</div>
)
})}
render() {
return (
// using a arrow function get the looping item and it's index (i)
this.state.data.map((item, i) => {
<li key={i}>Test</li>
})
);
}
const todoItems = [
{
id: 1,
text:"todo 1"
},
{
id: 2,
text:"todo 3"
},
{
id: 3,
text:"todo 3"
}
];
const todoItems = todos.map((todo) =>
<li key={todo.id}>
{todo.text}
</li>
);
import React from 'react';
import ReactDOM from 'react-dom';
function NameList(props) {
const myLists = props.myLists;
const listItems = myLists.map((myList) =>
<li>{myList}</li>
);
return (
<div>
<h2>React Map Example</h2>
<ul>{listItems}</ul>
</div>
);
}
const myLists = ['A', 'B', 'C', 'D', 'D'];
ReactDOM.render(
<NameList myLists={myLists} />,
document.getElementById('app')
);
export default App;
const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map((number) => number * 2);
console.log(doubled);
<style>.leaflet-container { height: 400px; width: 800px;}</style>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.3.1/leaflet.css">