Skip to content

Instantly share code, notes, and snippets.

@yefim
Created April 26, 2015 17:41
Show Gist options
  • Save yefim/65293ef83cd6ec7572bc to your computer and use it in GitHub Desktop.
Save yefim/65293ef83cd6ec7572bc to your computer and use it in GitHub Desktop.
Using bind to set parameters
var Item = React.createClass({
render: function() {
return (
<div onClick={this.props.handleClick.bind(this, this.props.item)}>{this.props.item}</div>;
);
}
})
var List = React.createClass({
handleClick: function(item) {
console.log(item);
},
render: function() {
var list = ['a', 'b', 'c'];
var self = this;
var items = list.map(function(item) {
return <Item handleClick={self.handleClick} item={item} />;
})
}
return (
<div>{items}</div>
);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment