Created
November 12, 2014 07:15
-
-
Save vipulnsward/90fc86a5b4d22f8177d7 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/temot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://fb.me/react-with-addons-0.11.0.js"></script> | |
<body> | |
<script id="jsbin-javascript"> | |
/** @jsx React.DOM */ | |
var App = React.createClass({displayName: 'App', | |
getInitialState: function() { | |
var date = new Date(); | |
var hour = date.getHours(); | |
var minute = date.getMinutes(); | |
var second = date.getSeconds(); | |
return {hour: hour, minute: minute, second: second}; | |
}, | |
clockTick: function(){ | |
var date = new Date(); | |
var hour = date.getHours(); | |
var minute = date.getMinutes(); | |
var second = date.getSeconds(); | |
this.setState({hour: hour, minute: minute, second: second}); | |
}, | |
render: function() { | |
return React.DOM.h1(null, | |
this.state.hour, ":", | |
this.state.minute, ":", | |
this.state.second | |
) | |
}, | |
componentDidMount: function(){ | |
setInterval(this.clockTick, 1000); | |
} | |
}); | |
React.renderComponent(App(null), document.body); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><script src="//fb.me/react-with-addons-0.11.0.js"><\/script> | |
<body></script> | |
<script id="jsbin-source-javascript" type="text/javascript">/** @jsx React.DOM */ | |
var App = React.createClass({ | |
getInitialState: function() { | |
var date = new Date(); | |
var hour = date.getHours(); | |
var minute = date.getMinutes(); | |
var second = date.getSeconds(); | |
return {hour: hour, minute: minute, second: second}; | |
}, | |
clockTick: function(){ | |
var date = new Date(); | |
var hour = date.getHours(); | |
var minute = date.getMinutes(); | |
var second = date.getSeconds(); | |
this.setState({hour: hour, minute: minute, second: second}); | |
}, | |
render: function() { | |
return <h1> | |
{this.state.hour}: | |
{this.state.minute}: | |
{this.state.second} | |
</h1> | |
}, | |
componentDidMount: function(){ | |
setInterval(this.clockTick, 1000); | |
} | |
}); | |
React.renderComponent(<App />, document.body);</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @jsx React.DOM */ | |
var App = React.createClass({displayName: 'App', | |
getInitialState: function() { | |
var date = new Date(); | |
var hour = date.getHours(); | |
var minute = date.getMinutes(); | |
var second = date.getSeconds(); | |
return {hour: hour, minute: minute, second: second}; | |
}, | |
clockTick: function(){ | |
var date = new Date(); | |
var hour = date.getHours(); | |
var minute = date.getMinutes(); | |
var second = date.getSeconds(); | |
this.setState({hour: hour, minute: minute, second: second}); | |
}, | |
render: function() { | |
return React.DOM.h1(null, | |
this.state.hour, ":", | |
this.state.minute, ":", | |
this.state.second | |
) | |
}, | |
componentDidMount: function(){ | |
setInterval(this.clockTick, 1000); | |
} | |
}); | |
React.renderComponent(App(null), document.body); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment