function App() {
const handleClick = e => {
console.log(e.type);
setTimeout(() => console.log(e.type), 0);
};
return <button onClick={handleClick}>Click</button>;
}
0
What will be the output?
subina kallyani
hard
1completed
42
Answer
- First log:
"click" - Second log:
null→ SyntheticEvent is pooled after the handler.
Usee.persist()to prevent React from reusing the event object in async code.
Click to Reveal Answer
Tap anywhere to see the solution
Revealed
Comments0