-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcounter.html
70 lines (57 loc) · 1.51 KB
/
counter.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 lang="en">
<head>
<meta charset="UTF-8">
<title>React!</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- tady -->
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://unpkg.com/react@15/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
<script src="https://unpkg.com/react-dom@15/dist/react-dom-server.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
<!-- tady -->
</head>
<body>
<div id="app"></div>
</body>
<script type="text/babel" data-presets="es2015,stage-0,react">
(function() {
const project = {
id: 123,
name: 'My Project'
}
class Counter extends React.Component {
state = {
count: this.props.count,
}
componentDidMount() {
store.addEventListner('change', this._handleChange)
}
_handleChange = () => {
this.setState({
project: store.getProjectById(this.props.projectId)
})
}
static defaultProps = {
count: 1111
}
handleClick = () => {
this.setState({
count: (this.state.count || this.props.count) + 1,
})
}
render() {
return (
<div>
<button className="btn btn-success"
onClick={this.handleClick}
>{`You clicked: ${this.state.count || this.props.count } times`}</button>
</div>
)
}
}
ReactDOM.render(<Counter projectId={33}/>, document.getElementById('app'))
})()
</script>
</html>