return <div />;
}
return React.cloneElement(
React.Children.only(this.props.children),
this.state.childProps
);
}
getChildName() {
if (!this._childName){
this._childName = (React.Children.only(
this.props.children
).type.displayName||'Unknown').split('.').pop();
}
return this._childName;
}
}
module.exports = RootElement;
RootElement.propTypes = {
listen: PropTypes.func,
when: PropTypes.object, // A promise.
childProps: PropTypes.object,
_isRootElement: PropTypes.bool,
children: PropTypes.node,
subscribe: PropTypes.func,
unsubscribe: PropTypes.func,
};
RootElement.defaultProps = {
_isRootElement: true,
};
RootElement.isRootElement = function(element) {
return element && element.props && element.props._isRootElement;
}
RootElement.getRootElementAttributes = function(element) {
var props = element.props;
var attrs = {};
if (props.className) attrs.class = props.className;