Why is useEffect running after render?
There is no differnece between [] and [number] in this case.
import { useEffect, useState } from 'react';
export const Timer = () => {
const [number, setNumber] = useState(0);
useEffect(() => {
let id = setInterval(() => setNumber((prev) => prev + 1), 1000);
return () => clearInterval(id);
}, []);
return (
<div>
<h1>Timer</h1>
<p>{number}</p>
</div>
);
};