import React from 'react';
import ReactDOM from 'react-dom';
import ControlsMenuTabSection from './controls-menu-tab-section.jsx';
class ControlsMenuTab extends React.Component {
constructor(props) {
super(props);
this.getBetterChildren = this.getBetterChildren.bind(this);
this.alertParentOfError = this.alertParentOfError.bind(this);
}
alertParentOfError(xhr, status, err) {
if(this.props.passErr) {
this.props.passErr(xhr, status, err);
} else {
console.error(xhr, status, err.toString());
}
}
getBetterChildren() {
Eif (this.props.children) {
return React.Children.map(this.props.children, (child, i) => {
Iif (child.type === ControlsMenuTabSection) {
return React.cloneElement(child, { passErr: this.alertParentOfError });
}
return child;
});
}
}
render () {
return (
<div className="tab-pane" id={this.props.id}>
{this.getBetterChildren()}
</div>
);
}
}
export default ControlsMenuTab;
|