There should not be an issue with re-rendering every second. Infact in a clock like this that should be desirable. Have you checked if your clock is working?
useEffect(() => {
let now = new Date()
while (now.getSeconds() !== 0) {
const interval = window.setInterval(() => {now = new Date()}, 1000)
return () => window.clearInterval(interval);
}
setTime(now);
}, [])
You seem to return out of your useEffect before you've set state. Which means your UI would not be receiving any state updates.
useEffect(() => {
// Adjust this to 60 * 1000 for 1 min (not required)
const refreshTime = 1000;
const interval = setInterval(() => {
setTime(new Date())
}, refreshTime)
return () => {
clearInterval(interval)
}
}, []);