title: Is there a way to calculate the duration of a task when the app is in offline mode in React-native?
body: <p>I want to calculate the duration of a ticket created when the app is in offline and display a toast message to sync the data within 24Hrs in the offline mode itself.</p>
  
  <pre><code> static getDerivedStateFromProps(props, state) {
    if (!props.isOnline &amp;&amp; !props.isInternetReachable) {
     let curr_time = moment().format();
     let offlineTicketCreatedTime = state.offlineNewTicketList.length &gt; 0
            ? moment(state.offlineNewTicketList[0].Created).format()
            : 0;
     let difference = parseFloat(
          moment
            .duration(
              moment.utc(curr_time).diff(moment(offlineTicketCreatedTime))
            )
            .asSeconds()
        );
     if (difference &gt; 1400) {
      alert("Sync now!!!");
     }
    }
  return null; }
  </code></pre>
  
  <p>But this works only one time. I want to calculate the time in background even when I'm in other screens in offline mode. I want to run this calculation as a timer. And when the time is 23Hrs 50min a toast needs to be shown.</p>