export default function Component(){
function handleClick() {
alert('Clicked!');
}
return <div onClick={handleClick}></div>;
}
Inline event handlers:
<button onClick={() => {
alert('Clicked!');
}}>
Make event handlers inside components before return statement and then pass it as props, don't use parentheses or it would call it immediately.
Used for events
const toggleTopping = ({target}) => {
const clickedTopping = target.value;
}
Information
Click title link to view more
onClick
onMouseOver
onDoubleClick
onChange
onSubmit
A list of events supported by React.