0

I'm making a react native app and I'm trying to show the time and update it every second. My code

const [currentTime, setCurrentTime] = useState('')

useEffect(() => {
  setInterval(myTimer, 1000);

  function myTimer() {
    const date = new Date();
    setCurrentTime( date.toLocaleTimeString());
    console.log(currentTime)
  }
}, []);
 

I get the same time every time it prints to console, why it isn't working

m3k_1
  • 351
  • 1
  • 8

0 Answers0