Skip to content

Instantly share code, notes, and snippets.

@behnamazimi
Created March 4, 2019 08:10
Show Gist options
  • Save behnamazimi/d8d0608e317296bcf2860d1b8279da2d to your computer and use it in GitHub Desktop.
Save behnamazimi/d8d0608e317296bcf2860d1b8279da2d to your computer and use it in GitHub Desktop.
Say By to .bind(this)
// Dirty Code
class MyComponent extends Component {
constructor(props) {
super(props)
this.handleOne = this.handlerOne.bind(this)
this.handleTwo = this.handlerTwo.bind(this)
this.handleThree = this.handlerThree.bind(this)
}
handleOne() {
}
handleTwo() {
}
handleThree() {
}
}
// Clean Code
class MyComponent extends Component {
handleOne = () => {
}
handleTwo = () => {
}
handleThree = () => {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment