class App extends React.Component {
method(){
console.log(this);
}
render(){
return (<div>
<button onClick={this.method}>Try it</button>
</div>)
}
}
ReactDOM.render(<App/>, document.getElementById('demo'));
I think the button element is driving the method so the button element object should have been returned instead of undefined
Why so happens?Why you need to use this.method.bind(this) to have it worked?