Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. var Counter = React.createClass({
  2. getInitialState: function() {
  3. return {secondsElapsed: 0};
  4. },
  5. tick: function() {
  6. this.setState({secondsElapsed: this.state.secondsElapsed + 1});
  7. },
  8. componentDidMount: function() {
  9. this.interval = setInterval(this.tick, 1000);
  10. },
  11. componentWillUnmount: function() {
  12. clearInterval(this.interval);
  13. },
  14. render: function() {
  15. return (
  16. <div>
  17. <h1>
  18. Counter from '{this.props.title}' page: {this.state.secondsElapsed}
  19. </h1>
  20. </div>
  21. );
  22. }
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement