Forked from ryanflorence/how-shall-i-maintain-referential-equality.jsx
Created
October 14, 2017 15:56
-
-
Save EmperorEarth/404e9ae025408cb97db1ec203a0714db to your computer and use it in GitHub Desktop.
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
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