I'm trying to implement a simple timer that just counts up continuously every second. I'm using react to render the result. The code is only a few lines and makes sense from what I've been reading. It adds and renders properly for the first 6 seconds; however, it just starts displaying random numbers after the 7th or 8th, OR the timer becomes erroneous and updates every random second. My code is as follows, am I doing something wrong? Thanks!
import React, {useState} from 'react';
function App() {
const [count, setCount] = useState(0);
setInterval(()=>{setCount(count + 1)}, 1000)
return (
<div className="welcome">
{count}
</div>
);
}
export default App;