Created
October 13, 2015 06:35
-
-
Save evanscottgray/2ad7d39c8865877a08f8 to your computer and use it in GitHub Desktop.
created by https://github.com/tr3buchet/gister
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 BaseComponent extends React.Component { | |
_bind(...methods) { | |
methods.forEach( (method) => this[method] = this[method].bind(this) ); | |
} | |
} | |
class ExampleComponent extends BaseComponent { | |
constructor() { | |
super(); | |
this._bind('_handleClick', '_handleFoo'); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from http://www.newmediacampaigns.com/blog/refactoring-react-components-to-es6-classes