K
K
KirylLapouski2018-05-09 11:22:58
JavaScript
KirylLapouski, 2018-05-09 11:22:58

Is it possible to add multiple event handlers in react?

It is necessary to add two different independent event handlers to the button click.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-05-09
@KirylLapouski

Example extends Component {
  handleClick = e => {
    const { firstHandler, secondHandler } = this.props;

    firstHandler(e);
    secondHander(e);
  };

  render() {
    return <button onClick={this.handleClick}>Click me</button>;
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question