mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
Judging by https://github.com/rackt/react-router/blob/master/docs/API.md#children-1 and a few inspections in the code, as well as tests, the `children` prop injected into routes can only ever be a single React Element object. This allows us to easily get the active route of a child (if there is an active route) by querying the `children`’s route prop.
32 lines
786 B
JavaScript
32 lines
786 B
JavaScript
'use strict';
|
|
|
|
import React from 'react';
|
|
|
|
import AppBase from './app_base';
|
|
import Header from './header';
|
|
|
|
|
|
let AscribeApp = React.createClass({
|
|
propTypes: {
|
|
activeRoute: React.PropTypes.object.isRequired,
|
|
children: React.PropTypes.element.isRequired,
|
|
routes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired
|
|
},
|
|
|
|
render() {
|
|
const { activeRoute, children, routes } = this.props;
|
|
|
|
return (
|
|
<div className="ascribe-default-app">
|
|
<Header routes={routes} />
|
|
<div className="container ascribe-body">
|
|
{/* Routes are injected here */}
|
|
{children}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
});
|
|
|
|
export default AppBase(AscribeApp);
|