Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sanketmeghani/91a2b2258d0aebbb8512f5f1cc365fb3 to your computer and use it in GitHub Desktop.
Save sanketmeghani/91a2b2258d0aebbb8512f5f1cc365fb3 to your computer and use it in GitHub Desktop.
React event handler with parameters using bind in constructor
class MyComponent extends React.Component {
constructor() {
super();
this.handleClick = this.handleClick.bind(this, 'Parameter');
}
handleClick(param, e) {
console.log('Parameter', param);
console.log('Event', e);
}
render() {
<button onClick={this.handleClick}></button>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment