I'm trying to create a simple progress bar in react with 1sec increment but the the progress shows 2% increment at once. can someone please let me know what's wrong with this code and why it shows 2% increment instead of 1%.

```
useEffect(() => {
    const timer = setInterval(() => {
      setProgress((prev) => {
        if (prev < 100) {
          return prev + 1;
        }
        if (prev === 100) {
          clearInterval(timer);
        }
        return prev;
      });
    }, 1000);
  }, []);

```

Complete code is available in this codesandbox.
<https://codesandbox.io/s/progress-bar-in-react-ccty7w?file=/src/App.js>