1
0
mirror of https://github.com/ascribe/onion.git synced 2025-01-03 10:25:08 +01:00

Use object destructuring instead of omitFromObject

This commit is contained in:
Brett Sun 2016-02-26 10:20:56 +01:00
parent dcdae7b7b1
commit 916d06bc74

View File

@ -2,8 +2,6 @@
import React from 'react';
import { omitFromObject } from '../utils/general_utils';
const AppRouteWrapper = React.createClass({
propTypes: {
children: React.PropTypes.oneOfType([
@ -13,19 +11,18 @@ const AppRouteWrapper = React.createClass({
},
render() {
const propsToPropagate = omitFromObject(this.props, ['children']);
let { children, ...propsToPropagate } = this.props;
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) => {
children = React.Children.map(children, (child) => {
return React.cloneElement(child, propsToPropagate);
});
}
return (
<div className="container ascribe-body">
{childrenWithProps}
{children}
</div>
);
}