Skip to content
Justice Tech School

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

Which is right?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.