Tech Challenge
2026-11-28
⚛️
Daily Tech Challenge
React
medium
Question 1 of 5
Porting a class component to hooks, a developer keeps the old setState habit and passes a callback as a SECOND argument to the useState setter. In a React development build, what happens when the user clicks the button once?
Example
function Counter() {
const [count, setCount] = useState(0);
function handleClick() {
setCount(count + 1, () => {
console.log('updated!');
});
}
return <button onClick={handleClick}>{count}</button>;
}Saturday, November 28, 2026 · A new challenge drops every day