Forked from ryanflorence/how-shall-i-maintain-referential-equality.jsx
Created
February 20, 2018 09:13
-
-
Save epoch/4f4fa001c04d01a7ca6a8146333baf08 to your computer and use it in GitHub Desktop.
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 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