Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stephenwil/eef9b2978c84a253e0200b992b227d33 to your computer and use it in GitHub Desktop.
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
// 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