title: React. How to decrease timer value in localstorage by one?
body: <p>How to decrease timer value in <code>localstorage</code> by one? I used the <a href="https://usehooks.com/useLocalStorage/" rel="nofollow noreferrer">useLocalStorage</a> hook, but the value does not dynamically decrease by one. Thank you!</p>
  <p>Timer:</p>
  <pre><code>const [timeLeft, setTimeLeft] = useLocalStorage('timer',  5 * 60)
  
  const getPadTime = (time) =&gt; time.toString().padStart(2, '0')
  
  const minutes = getPadTime(Math.floor(timeLeft / 60))
  const seconds = getPadTime(timeLeft - minutes * 60)
  
  useEffect(() =&gt; {
      const interval = setInterval(() =&gt; {
          setTimeLeft((timeLeft) =&gt; (timeLeft &gt;= 1 ? timeLeft - 1 : setDisabled() ||  5 * 60))
      }, 1000)
      return () =&gt; clearInterval(interval) 
  }, [])
  </code></pre>