React.addons.cloneWithProps
为什么以及如何对事件处理程序进行链接?
// All props were transferred from <Element /> to its child.
// Event handlers from <Element /> will chain with event handlers from its child.
var Case2 = React.createClass({
render: function () {
var child = React.Children.only(this.props.children);
return React.addons.cloneWithProps(child, this.props);
}
});
// All props were transferred from <Element /> to its child.
// Event handlers from <Element /> will override event handlers from its child.
var Case3 = React.createClass({
render: function () {
var child = React.Children.only(this.props.children);
return React.addons.cloneWithProps(child, _.omit(this.props, 'children'));
}
});
这是official documentation of the React.addons.cloneWithProps。它没有说明这种行为。
这是fiddle。