JavaScript Quiz Practice
Active Recall Drill Session
← Exit SessionQuestion 1 of 1
hardJavaScript
What does clicking the button log, one second after render?
code
function Counter() {
const [count, setCount] = useState(0);
useEffect(() => {
const id = setTimeout(() => console.log(count), 1000);
return () => clearTimeout(id);
}, []);
return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
}
// user clicks the button 3 times within the first second