反応コンポーネントに動的イベントをアタッチするのが困難です。次のコンポーネントがあります。
var ListItem = React.createClass({
render: function() {
return (
<li className="selector" >
<div className="column">
<h2 className="commentAuthor">
{this.props.author}
</h2>
<div>{this.props.children}</div>
</div>
</li>
);
}
});
var ListBox = React.createClass({
mixins : [MyMixin],
render : function() {
this.nodes = this.props.data.map(function(item) {
return <ListItem author={item.author}>{item.text}</ListItem>;
});
return (
<ul id="columns">
{this.nodes}
</ul>
);
}
});
ご覧のとおり、ListItem の className は「selector」に設定されています。この「セレクター」に基づいて、ノードにクエリを実行し、MyMixin でイベントを動的にアタッチします。
React.renderComponent(
<ListBox data={data} selector="li.selector" />,
document.getElementById('example')
);
私はReactを初めて使用するので、私の考えはすべて間違っているかもしれません。
よろしく