Handling Events in React
React uses camelCase syntax for events and passes a function as the handler.
function Button() {
function handleClick() {
alert('Button clicked!');
}
return <button onClick={handleClick}>Click me</button>;
}
- Events are synthetic and work the same across all browsers.
- You can pass inline functions or define them separately.