-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChapter06.html
48 lines (47 loc) · 1.13 KB
/
Chapter06.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
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Chapter 6!</title>
<script src="https://unpkg.com/react@15.6.1/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15.6.1/dist/react-dom.js"></script>
<style>
#container {
padding: 50px;
background-color: #FFF;
}
</style>
</head>
<body>
<div id="container"></div>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<!-- Your custom script here -->
<script type="text/babel">
class Display extends React.Component {
render() {
return <div /* inside tag comment is OK */>
<p>{this.props.color}</p>
<p>{this.props.num}</p>
<p>{this.props.size}</p>
{/* child comment needs curly braces to avoid being printed as part of HTML */}
</div>;
}
}
class Label extends React.Component {
render() {
return <Display {...this.props}/>;
}
}
class Shirt extends React.Component {
render() {
return <Label {...this.props}/>;
}
}
const destination = document.querySelector("#container");
ReactDOM.render(
<div>
<Shirt color="steelblue" num="3.14" size="medium"/>
</div>, destination);
</script>
</body>
</html>