I'm trying to create a simple timer in my react app that counts up from 0 to 10 and then stops. But I can't get it to work without getting caught in an infinite loop.

```
import React, { useState, useEffect } from "react";

const Countdown = () => {
  const [countdown, setCountdown] = useState(0);

  useEffect(() => {
    const interval = setInterval(() => {
      setCountdown(countdown + 1);
    }, 1000);
    if (countdown >= 10) {
      return () => clearInterval(interval);
    }
  }, [countdown]);

  return <div>{countdown}</div>;
};

export default Countdown;

```