Last active
April 3, 2016 19:51
-
-
Save sagiavinash/e5016db3e54146c26d45de7e01f0b9e6 to your computer and use it in GitHub Desktop.
Use Arrow functions for event callbacks instead of binded functions
This file contains hidden or 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
/* preferred way */ | |
handleClick={() => self.handleClick(index)} | |
//(or) | |
handleClick={e => self.handleClick(e, index)} | |
| |
/* current way */ | |
handleClick={this.handleClick.bind(this, index)} | |
//(or) | |
handleClick={this.handleClick.bind(null, index)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment