-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.jsx
62 lines (56 loc) · 1.42 KB
/
script.jsx
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// import React, { Component, Fragment } from "react";
// With React 16 it is possible now to return an Array of elements.
function Fruits(){
return (
<React.Fragment>
<li>Apple</li>
<li>Orange</li>
<li>Banana</li>
</React.Fragment>
);
}
// In React 16.2 support for fragments was added. It's a convenient way to return multiple children from a component’s render method.
function Glossary(props) {
return (
<dl>
{props.items.map(item => (
<React.Fragment key={item.id}>
<dt>{item.term}</dt>
<dd>{item.description}</dd>
</React.Fragment>
))}
</dl>
);
}
class App extends React.Component {
render() {
return(
<div>
<ul>
<li>Peach</li>
<li>Ananas</li>
<Fruits />
</ul>
<Glossary
items={
[
{
id: 1,
term: "HTML",
description:
"Is a descriptive language that specifies webpage structure"
},
{
id: 2,
term: "CSS",
description:
"Is a declarative language that controls how webpages look in the browser"
}
]
}
/>
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById("root"));