React Base Fiddle (JSX)
Starting point for creating JSFiddles with React. This uses React with Addons.
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://fb.me/react-with-addons-0.14.0.js"></script>
<script src="https://fb.me/react-dom-0.14.0.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>
<div id="container">
<div id="Clock"> </div>
</div>
JavaScript 1.7
var Clock = React.createClass({
setTime: function(){
var now = new Date();
this.setState({
hours: now.getHours(),
minutes: now.getMinutes(),
seconds: now.getSeconds()
});
},
componentWillMount: function(){
this.setTime();
},
componentDidMount: function(){
window.setInterval(function () {
this.setTime();
}.bind(this), 1000);
},
render: function() {
return(
<div className="Clock__time">
<span>{this.state.hours}:{this.state.minutes}</span><span className="Clock_time_secs">:{this.state.seconds}</span>
<div className="Clock__date">
MONDAY, 2 MARCH 2015
</div>
</div>
)
}
});
ReactDOM.render(<Clock />, document.getElementById('Clock'));