Created
May 5, 2016 12:04
-
-
Save stephenwil/eef9b2978c84a253e0200b992b227d33 to your computer and use it in GitHub Desktop.
REACTJS - Best practise with ES6 - A Component calling a method it owns with a parameters in scope at definition
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
// A component calling a method with parameters; Using ES6, so no need for bind as the arrow function does this | |
<select onChange={(event)=>this._handleSelectChange(x, index, event)} className="form-control" name={"os"+index}> | |
{eachOption} | |
</select> | |
// ES5 way using bind | |
<select onChange={this._handleSelectChange.bind(this,index)} className="form-control" name={"os"+index}> | |
{eachOption} | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment