title: React native: how can I extend this timer through an alert?
body: <p>I am new to react native. I have a countdown timer (currently set to 5 seconds) and when the time is up, I want an alert which gives the user an option to restart the timer. There will be other elements in the screen so I don't necessarily want a "refresh" (for example, if the user inputted some text, I don't want that to go away when the timer is extended).</p>
  
  <p>The alert pops up when the time is up, but I'm not sure how to reset the timer via the alert button.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React, { Component } from 'react';
  import {
    StyleSheet,
    TouchableOpacity,
    Text,
    View,
    TextInput,
    Alert,
  } from 'react-native'
  import CountDown from 'react-native-countdown-component';
  
  export default class Payment extends Component {
    constructor(props) {
      super(props);
  
      this.state = {
        timer: 5,
      };
    }
    
    timesUp = () =&gt; {
      Alert.alert(
        "Time's Up!",
        "How can we help you?",
        [
          { 
            text: "Extend Timer",
            // I want to restart the timer here
            onPress: this.setState(newTime =&gt; ({ timer: 5})) },
          {
            text: "Cancel",
            onPress: () =&gt; console.log("Cancel Pressed") },
        ],
        { cancelable: false }
      );
    }
  
    render() {
      return (
        &lt;View&gt;
          &lt;View style={{ marginTop: 20}}&gt;
            &lt;CountDown
              size={15}
              until={this.state.timer}
              onFinish={this.timesUp}
              digitStyle={{backgroundColor: '#FFF', borderWidth: 2, borderColor: '#cccccc'}}
              digitTxtStyle={{color: 'black'}}
              separatorStyle={{color: 'black'}}
              timeToShow={['M', 'S']}
              timeLabels={{m: null, s: null}}
              showSeparator
            /&gt;
        &lt;/View&gt;
      );
    }
  }</code></pre>
  </div>
  </div>
  </p>