Last active
August 29, 2015 14:28
-
-
Save cubdesign/70c6526e8583f8d26e3a to your computer and use it in GitHub Desktop.
Reactをes6で使う場合のbindの問題 ref: http://qiita.com/cubdesign/items/ee8bff7073ebe1979936
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
save(e){ | |
this.props // undefined になる | |
} | |
render (){ | |
return ( | |
<button onClick={this.save} />保存</button> | |
); | |
} |
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
save = function (e){ | |
this.props // undefined ではない | |
} | |
render = function (){ | |
return ( | |
<button onClick={this.save} />保存</button> | |
); | |
} |
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
constructor() { | |
super(); | |
this.save = this.save.bind(this); | |
} | |
render = function (){ | |
return ( | |
<button onClick={this.save} />保存</button> | |
); | |
} |
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
render = function (){ | |
return ( | |
<button onClick={this.save.bind(this)} />保存</button> | |
); | |
} |
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
render = function (){ | |
return ( | |
<button onClick={(event) => this.save(event)} />保存</button> | |
); | |
} |
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
render = function (){ | |
return ( | |
<button onClick={::this.save} />保存</button> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment