Forked from sanketmeghani/event-handlers-with-parameters-bind-constructor.js
Last active
November 30, 2017 18:56
-
-
Save BerkeleyTrue/0710685c366b8353602a24b5078e0208 to your computer and use it in GitHub Desktop.
React event handler with parameters using bind in constructor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyComponent extends React.Component { | |
constructor() { | |
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