- React events are named using camelCase, rather than lowercase.
- With JSX you pass a function as the event handler, rather than a string.
<button onClick={activateLasers}>
Activate Lasers
</button>
You cannot return false
to prevent default behavior in React. You must call preventDefault
explicitly.
function ActionLink() {
function handleClick(e) {
e.preventDefault();
console.log('The link was clicked.');
}
return (
<a href="#" onClick={handleClick}>
Click me
</a>
);
}