Skip to content

Instantly share code, notes, and snippets.

@edinsoncs
Created May 31, 2016 20:36
Show Gist options
  • Select an option

  • Save edinsoncs/483c009298ece04a153232df19783859 to your computer and use it in GitHub Desktop.

Select an option

Save edinsoncs/483c009298ece04a153232df19783859 to your computer and use it in GitHub Desktop.
function initializeReact() {
var corriendoEnReact = React.createClass({
render: function(){
var time = Math.round(this.props.elapsed / 100);
var segundos = time / 10 + (time % 10 ? '' : '.0' );
var mensaje = 'Estamos corriendo: ' + segundos + ' Segundos';
return React.DOM.h2(null, mensaje);
}
});
var iniciar = React.createFactory(corriendoEnReact);
var empezamos = new Date().getTime();
var closeItem = setInterval(function(){
ReactDOM.render(iniciar({elapsed: new Date().getTime() - empezamos}), document.getElementById("show"))
}, 50);
function stop() {
var close = document.getElementById("close");
close.addEventListener('click', function() {
clearInterval(closeItem);
});
}
stop();
}
initializeReact();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment