-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chapter03.html
65 lines (62 loc) · 1.63 KB
/
Chapter03.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>React!</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: #EEE;
}
#container h1 {
font-size: 48px;
font-family: sans-serif;
color: #0080A8;
}
</style>
</head>
<body>
<div id="container"></div>
<div id="container2"></div>
<!-- Load Babel for in-browser transpiling of JSX -->
<!-- If using babel-core, 5.8.38 is last version supporting transpiling JSX, which has since been deprecated, requiring the use of babel-standalone -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.38/browser.min.js"></script> -->
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<!-- Your custom script here -->
<script type="text/babel">
let destination = document.querySelector("#container");
ReactDOM.render(
<h1>Sherlock Holmes</h1>,
destination
);
/*
// non JSX version, pure JS, no need for babel
ReactDOM.render(React.createElement(
"h2",
null,
"Batman"), destination);
*/
class HelloWorld extends React.Component {
render() {
return <p>Hello, {this.props.greetTarget}!</p>;
}
}
class Buttonify extends React.Component {
render() {
return <div>
<button type={this.props.behavior}>{this.props.children}</button>
</div>;
}
}
ReactDOM.render(
<div>
<HelloWorld greetTarget="Iron Man"/>
<HelloWorld greetTarget="J R"/>
<Buttonify behavior="submit">SEND DATA</Buttonify>
</div>,
document.querySelector("#container2"));
</script>
</body>
</html>