Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save epoch/4f4fa001c04d01a7ca6a8146333baf08 to your computer and use it in GitHub Desktop.
Save epoch/4f4fa001c04d01a7ca6a8146333baf08 to your computer and use it in GitHub Desktop.
class Dashboard extends Component {
constructor(props) {
super(props)
// bind? slows down the initialization path, looks awful
// when you have 20 of them (I have seen your code, I know)
// and it increases bundle size
this.handleStuff = this.handleStuff.bind(this)
// _this is ugly.
var _this = this
this.handleStuff = function() {
_this.setState({})
}
// If you can use an ES class then you can probably use an arrow
// function (babel, or a modern browser). This isn't too bad but
// putting all of your handlers in the constructor is kind of
// not awesome
this.handleStuff = () => {
this.setState({})
}
}
// this is nice, but it isn't JavaScript, not yet anyway, so now
// we need to talk about how TC39 works and evaluate our draft
// stage risk tolerance
handleStuff = () => {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment