Handling Events
Pass a function to props such as onClick and onChange. Pass the function itself, not a call to it.
Example
function Btn() {
function handleClick(e) {
console.log('clicked', e.type);
}
return <button onClick={handleClick}>Click</button>;
}Exercise
Run on click.
<button ={f}>
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.