Skip to content Skip to sidebar Skip to footer

Onclick Event Not Firing In Reactjs

I need to fire an event on Click i.e handleClick. It's not working either on the image or any button. I tried arrow functions too but that is also of no use. Neither it is throwing

Solution 1:

Looks like this is a problem with "good old this context" :)

If you're using babel which can transpile ES2015 class properties you can do it like:

handleClick = () => {
  // ...
}

In other case just bind method in constructor:

this.handleClick = this.handleClick.bind(this);

More information can be found here: http://egorsmirnov.me/2015/08/16/react-and-es6-part3.html

Post a Comment for "Onclick Event Not Firing In Reactjs"