Bereaksi menghitung setiap detik
const [count, setCount] = React.useState(0);
useEffect(
() => {
const timer = () => {
setCount(count + 1);
}
// if you want it to finish at some point
if (count >= 10) {
return;
}
const id = setInterval(timer, 1000);
return () => clearInterval(id);
},
[count]
);
Zwazel