0

What will be the output?

author
subina kallyani
hard
1
42
function App() {
const handleClick = e => {
console.log(e.type);
setTimeout(() => console.log(e.type), 0);
};

return <button onClick={handleClick}>Click</button>;
}
Answer
  • First log: "click"
  • Second log: null → SyntheticEvent is pooled after the handler.


    Use e.persist() to prevent React from reusing the event object in async code.

Click to Reveal Answer

Tap anywhere to see the solution

Revealed

Comments0