forked from Lalitj03/plunkreactjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.jsx
More file actions
43 lines (37 loc) · 1.05 KB
/
Copy pathscript.jsx
File metadata and controls
43 lines (37 loc) · 1.05 KB
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
var Button = React.createClass({
localHandleClick: function() {
this.props.localHandleClick(this.props.increment);
},
render: function() {
return (
<button onClick={this.localHandleClick}>+{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={10} />
<Button localHandleClick={this.handleClick} increment={100} />
<Result localCounter={this.state.counter} />
</div>
)
}
} );
React.render(<Main />, document.getElementById("root"));