2016-01-11 14:00:09 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
import { omitFromObject } from '../utils/general_utils';
|
|
|
|
|
|
|
|
const AppRouteWrapper = React.createClass({
|
|
|
|
propTypes: {
|
|
|
|
children: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.arrayOf(React.PropTypes.element),
|
|
|
|
React.PropTypes.element
|
|
|
|
]).isRequired
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const propsToPropagate = omitFromObject(this.props, ['children']);
|
|
|
|
|
|
|
|
let childrenWithProps = this.props.children;
|
|
|
|
// If there are more props given, propagate them into the child routes by cloning the routes
|
|
|
|
if (Object.keys(propsToPropagate).length) {
|
|
|
|
childrenWithProps = React.Children.map(this.props.children, (child) => {
|
|
|
|
return React.cloneElement(child, propsToPropagate);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2016-02-05 10:38:59 +01:00
|
|
|
<div className="container ascribe-body">
|
2016-01-11 14:00:09 +01:00
|
|
|
{childrenWithProps}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default AppRouteWrapper;
|