onClick Event binding and get event name in ReactJs

Create React App

Type the following command to create a new react app:

npx create-react-app demo

Now, go to the project folder:

cd demo

Now, update default App.js with below code snippet


import React, { Component } from 'react';
class App extends Component {
  constructor(props) {
    this.handleClick = this.handleClick.bind(this);
  handleClick = (event) => {
  render() {
    return (
        <div className="text-center">
          <button className="btn btn-secondary" onClick={this.handleClick}>
            Click Me
export default App;
Most Helpful This Week