-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexBackupPart1.html
53 lines (53 loc) · 1.38 KB
/
indexBackupPart1.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
<!DOCTYPE html>
<html>
<head>
<title>ReactPluralSight-1</title>
</head>
<body>
<div id="root"></div>
<script src="https://fb.me/react-15.1.0.min.js"></script>
<script src="https://fb.me/react-dom-15.1.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
<script type="text/babel">
var Button = React.createClass({
localHandleClick : function(){
this.props.localHandleClick(this.props.increment);
},
render: function(){
return(
<button onClick={this.localHandleClick}>Inc.Counter {this.props.increment}</button>
);
}
});
var Result = React.createClass({
render:function(){
return(
<div>{this.props.localCounter}</div>
);
}
});
var Main = React.createClass({
getInitialState:function(){
return {counter:0};
},
handleClick:function(increment){
this.setState({counter:this.state.counter + increment});
},
render:function(){
return(
<div>
<Button localHandleClick={this.handleClick} increment={1} />
<Button localHandleClick={this.handleClick} increment={5} />
<Button localHandleClick={this.handleClick} increment={8} />
<Button localHandleClick={this.handleClick} increment={11} />
<Result localCounter={this.state.counter} />
</div>
);
}
});
ReactDOM.render(<Main />,
document.getElementById("root")
);
</script>
</body>
</html>