I have a question about passing arguments to React click handlers. I have the following code, but for some reason the node argument is not passed to the toggle function. Shouldn't it? It's defined this way because it's a recursive component.
var Element = React.createClass({
toggle: function(e,node){
},
render: function(){
var nodes = this.props.children.map(function(n){
return <Element node={n} text={n.text} children={n.children} />
});
return (
<span onClick={this.toggle.bind(this,this.props.node)}>{this.props.text}</span>
);
}
});
this.props.node. You can just accessthis.props.nodein the toggle method.