0

When I want to trigger something with the onClick JSX event.

With the arrow function the event is triggered once

<button onClick={() => console.log("This button was clicked")}>Click Me!</button>

But without the arrow function the event is triggered twice

<button onClick={console.log("This button was clicked")}>Click Me!</button>

Can someone explain why this happens?

0 Answers0