-
Notifications
You must be signed in to change notification settings - Fork 0
/
key.html
35 lines (33 loc) · 1023 Bytes
/
key.html
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
<html>
<head>
<title>map</title>
<script crossdomain src="https://unpkg.com/react@16/umd/react.development.js"> </script>
<script crossdomain src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"> </script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"> </script>
</head>
<body>
<div id="container">
</div>
<script type="text/babel">
//key-value pairs
function ListComponent(props) {
const listitems = myList.map((item) =>
<li key = {item.id}>{item.value}</li>
);
return (
<ul>{listitems}</ul>
);
}
const myList = [
{id: "a", value: "orange"},
{id: "b", value: "apple"},
{id: "c", value: "strawberry"},
{id: "d", value: "blueberry"},
{id: "e", value: "avacado"}
]
ReactDOM.render(
<ListComponent />,document.getElementById("container")
);
</script>
</body>
</html>