import React, { Component, PropTypes, createElement } from 'react';

function timer(delay) {
    return function TimerHoc(TimedComponent) {
        class Timer extends Component {
            constructor(props) {
                super(props);
                this.state = { tick: 0 };
                this.setInterval = ::this.setInterval;
                this.stop = ::this.stop;
            }

            setInterval() {
                this.timer = setInterval(() => {
                    this.setState({ tick: this.state.tick + 1 });
                }, delay);
            }

            stop() {
                clearInterval(this.timer);
            }

            componentDidMount() {
                this.setInterval();
            }

            componentWillUnmout() {
                this.stop();
            }

            render() {
                const { props, stop } = this.props;
                const { tick } = this.state;

                return createElement(TimedComponent, { ...props, tick, delay, stop });
            }
        };

        const componentName = TimedComponent.displayName || TimedComponent.name || 'Component';
        Timer.displayName = `Timer@${delay}[${componentName}]`;

        return Timer;
    };
}

export default timer;

@@ -9,49 +9,8 @@
 eact
-, %7B Component, PropTypes, createElement %7D
  fro
@@ -20,16 +20,16 @@
 react';%0A
+
 %0Afunctio
@@ -120,16 +120,22 @@
 extends 
+React.
 Componen
@@ -267,24 +267,23 @@
 this.set
-Interval
+Timeout
  = ::thi
@@ -287,24 +287,23 @@
 this.set
-Interval
+Timeout
 ;%0A      
@@ -371,20 +371,99 @@
  set
-Interval() %7B
+Timeout() %7B%0A                const duration = delay - (this.startTime - Date.now()) %25 delay;
 %0A   
@@ -491,24 +491,23 @@
 er = set
-Interval
+Timeout
 (() =%3E %7B
@@ -569,24 +569,63 @@
 ick + 1 %7D);%0A
+                    this.setTimeout();%0A
             
@@ -696,24 +696,23 @@
    clear
-Interval
+Timeout
 (this.ti
@@ -792,18 +792,62 @@
 is.s
-etInterval
+tartTime = Date.now();%0A                this.setTimeout
 ();%0A
@@ -1062,16 +1062,16 @@
 state;%0A%0A
-
         
@@ -1085,16 +1085,22 @@
  return 
+React.
 createEl

use setTimeout rather than setInterval to avoid drifting