Can't perform a React state update on an unmounted component for setInterval

Solution 1:

You need to cleanup the setInterval timer on component unmount, like:

useEffect(() => {
  const interval = setInterval(() => setDateState(new Date()), 1000);

  return () => {
    clearInterval(interval);
  }
}, []);