title: create timer with react native using es6
body: <p>I am looking to add a timer to my app which is built using react native.</p>
  
  <p>I have looked at the link to the <a href="https://facebook.github.io/react-native/docs/timers.html#content" rel="noreferrer">timer mixin</a> in the documentation however I have built the rest of the app using es6 so this won't be compatible.</p>
  
  <p>I have tried the below.</p>
  
  <p>In my Main class I have a function called <code>getTimerCountDown</code></p>
  
  <pre><code>getTimerCountDown() {
      setTimeout(() =&gt; {
        this.setTimeRemaining(this.getTimeRem()-1);
      }, 1000);
  }
  
  getTimeRem() {
      return this.state.timeRemaining;
  }
  </code></pre>
  
  <p>I have tried calling this in <code>componentDidUpdate</code> as shown below. This works as I want it to if I don't make any other interactions with the UI.</p>
  
  <p>If I do (eg I have a button I can click on the view.) as `componentDidUpdate gets called again the conunter gets really quick (as it is getting called x number of times)</p>
  
  <pre><code>componentDidUpdate(){
      this.getTimerCountDown();
  }
  </code></pre>
  
  <p>I am not sure if I am completly on the wrong track here or a small change to what I have done can get me what I want.
  What is the best way to get a countdown timer working in react native using es6?</p>
  
  <p>Timer Class 
  on main page</p>
  
  <pre><code>&lt;Timer timeRem={this.getTimeRem()} /&gt;
  </code></pre>
  
  <p>returns</p>
  
  <pre><code>render(){
      return (
          &lt;View style={styles.container}&gt;
              &lt;Text&gt; This is the Timer : {this.props.setTimer}  - {this.props.timeRem} &lt;/Text&gt;
          &lt;/View&gt;
      )
  }
  </code></pre>