Basic Event Handling

Handling Events in Functional Components

function functionClick() {
  function clickHandler() {
    console.log('Button clicked');
  }
  return (
    <div>
      <button onClick={clickHandler}>
        Click
      </button>
    </div>
  )
}

Handling Events in Class Components

class ClassClick extends Component {
  clickHandler() {
    console.log('Button clicked');
  }
  
  render() {
    return (
      <div>
        <button onClick={this.clickHandler}>
          Click
        </button>
      </div>
    )
  }
}

References

Previous
Next

Destructuring Properties

Binding Event Handlers