This repository has been archived by the owner on Jun 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (65 loc) · 1.93 KB
/
index.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
66
67
68
69
70
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>React Introduction</title>
<!-- Bootstrap -->
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- React CDN -->
<script src="https://unpkg.com/react@latest/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@latest/dist/react-dom.js"></script>
<!-- Babel-standalone, allowing JSX compilation in-browser -->
<script src="https://unpkg.com/[email protected]/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const realRootNode = document.getElementById('root');
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {
clicks: props.clickCount
};
}
increment() {
this.setState({
clicks: ++this.state.clicks
})
}
render() {
const { clicks } = this.state;
return(
<div>
<h1>Will it rain today in Pittsburgh?</h1>
<h2>Yes!</h2>
{ clicks > 1 ?
<h3>I've already told you <span className="count">{ clicks }</span> times!</h3>
: null
}
<button
className="btn btn-primary"
onClick={ this.increment.bind(this) }>
Check again?
</button>
</div>
)
}
}
ReactDOM.render(<Counter clickCount="1"/>, realRootNode);
</script>
<style>
body {
background-color: lightblue;
margin: 5%;
}
h2 {
color: green;
margin: 10%;
}
.count {
color: red;
}
</style>
</body>
</html>