-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpinner.html
62 lines (57 loc) · 1.37 KB
/
Spinner.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>ReactJS </title>
<script src="react.js"></script>
<script src="react-dom.js"></script>
<script src="browser.min.js"></script>
<style>
input {
margin : 10px;
}
</style>
</head>
<body>
<script type="text/babel">
var Spinner = React.createClass({
getInitialState : function(){
return {
value : 0
};
},
increment : function(){
this.setState({value : ++this.state.value});
},
decrement : function(){
this.setState({value : --this.state.value});
},
render : function(){
console.log("Component Rendered");
return (<div>
<input type="button" value="Down" onClick={this.decrement} />
<span>{this.state.value}</span>
<input type="button" value="Up" onClick={this.increment}/>
</div>);
}
});
var Timmer = React.createClass({
componentDidMount : function(){
setInterval(function(){
this.setState({value : new Date().toString()});
}.bind(this),1000);
},
getInitialState : function(){
return {
value : new Date().toString()
};
},
render : function(){
return (<div>Current Time is {this.state.value}</div>)
}
});
ReactDOM.render(<Timmer />, document.body);
</script>
<!-- ReactDOM.render(<Content title="Welcome to React" message="Hey You"/>, document.body); -->
</body>
</html>