JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<div id="time"></div>

JavaScript

function countDown(minutes, seconds) {
  var currentTime;

  function twoDigits(n) {
    return (n <= 9 ? '0' + n : n);
  }

  function updateTimer() {
    msLeft = endTime - (+new Date);
    time = new Date(msLeft);
    hours = time.getUTCHours();
    mins = time.getUTCMinutes();
    currentTime = (hours ? hours + ':' + twoDigits(mins) : mins) + ':' + twoDigits(time.getUTCSeconds());
    localStorage.setItem('timer', currentTime);
    $('#time').text(currentTime);
    countDownTimer = setTimeout(updateTimer, time.getUTCMilliseconds() + 500);
  }

  endTime = (+new Date) + 1000 * (60 * minutes + seconds) + 500;
  updateTimer();
}

if (localStorage.getItem('timer')) {
  localTime = localStorage.getItem('timer');
  var minutes = parseInt(localTime.substr(0, localTime.indexOf(':')));
  var seconds = parseInt(localTime = localTime.split(':')[1]);

  countDown(minutes, seconds);
} else {
  countDown(120, 0);
}