var TIMER_COMPONENT = ` var Timer = React.createClass({ getInitialState: function() { return {secondsElapsed: 0}; }, tick: function() { this.setState({secondsElapsed: this.state.secondsElapsed + 1}); }, componentDidMount: function() { this.interval = setInterval(this.tick, 1000); }, componentWillUnmount: function() { clearInterval(this.interval); }, render: function() { return (
Seconds Elapsed: {this.state.secondsElapsed}
); } }); React.render(, mountNode); `; React.render( , document.getElementById('timerExample') );