mirror of
https://github.com/ascribe/onion.git
synced 2025-01-20 17:51:25 +01:00
Use object destructuring instead of omitFromObject
This commit is contained in:
parent
dcdae7b7b1
commit
916d06bc74
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { omitFromObject } from '../utils/general_utils';
|
|
||||||
|
|
||||||
const AppRouteWrapper = React.createClass({
|
const AppRouteWrapper = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
children: React.PropTypes.oneOfType([
|
children: React.PropTypes.oneOfType([
|
||||||
@ -13,19 +11,18 @@ const AppRouteWrapper = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
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 there are more props given, propagate them into the child routes by cloning the routes
|
||||||
if (Object.keys(propsToPropagate).length) {
|
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 React.cloneElement(child, propsToPropagate);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container ascribe-body">
|
<div className="container ascribe-body">
|
||||||
{childrenWithProps}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user