Effects synchronize
useEffect isn't βrun after renderβ β it's βkeep this external thing in sync with these values.β List every value you read in the dependency array, and clean up whatever you set up:
useEffect(() => {
const id = setInterval(tick, 1000);
return () => clearInterval(id);
}, [tick]);If an effect doesn't depend on any prop or state, it probably shouldn't be an effect at all.