-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlist.js
More file actions
43 lines (37 loc) · 737 Bytes
/
list.js
File metadata and controls
43 lines (37 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import ReactDOM from 'react-dom';
const data = [
{ name: 'Daniel', age: 25 },
{ name: 'John', age: 24 },
{ name: 'Jen', age: 31 },
];
const DataItem = ({ name, age}) => {
return (
<li>
<span>{name}{` `}</span>
<span>{age}</span>
</li>
);
};
const DataList = () => {
return (
<div>
<h2>Data List</h2>
<ul>
{data.map((dataItem, index) => {
return (
<DataItem
name={dataItem.name}
age={dataItem.age}
key={`data-item-${index}`}
/>
);
})}
</ul>
</div>
);
};
ReactDOM.render(
<DataList data={ data } />,
document.getElementById('root')
);