1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 21:52:08 +02:00
onion/js/components/ascribe_app.js

58 lines
1.6 KiB
JavaScript
Raw Normal View History

'use strict';
2015-05-13 16:26:12 +02:00
import React from 'react';
import { History } from 'react-router';
import Header from './header';
import Footer from './footer';
2015-06-08 18:14:25 +02:00
import GlobalNotification from './global_notification';
2015-05-15 15:38:25 +02:00
import AppConstants from '../constants/application_constants';
2015-05-18 18:00:12 +02:00
2015-05-20 12:00:16 +02:00
let AscribeApp = React.createClass({
propTypes: {
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.element
2015-10-01 14:00:56 +02:00
]),
routes: React.PropTypes.arrayOf(React.PropTypes.object),
location: React.PropTypes.object
},
mixins: [History],
componentDidMount() {
this.history.locationQueue.push(this.props.location);
},
componentWillReceiveProps(nextProps) {
const { locationQueue } = this.history;
locationQueue.unshift(nextProps.location);
// Limit the number of locations to keep in memory to avoid too much memory usage
if (locationQueue.length > AppConstants.locationThreshold) {
locationQueue.length = AppConstants.locationThreshold;
}
},
2015-05-18 18:00:12 +02:00
render() {
const { children, routes } = this.props;
2015-05-18 18:00:12 +02:00
return (
2015-07-13 14:29:20 +02:00
<div className="container ascribe-default-app">
2015-10-06 10:20:36 +02:00
<Header routes={routes} />
{/* Routes are injected here */}
2015-10-09 02:00:02 +02:00
<div className="ascribe-body">
{children}
2015-10-09 02:00:02 +02:00
</div>
2015-07-02 15:41:17 +02:00
<Footer />
2015-06-08 18:14:25 +02:00
<GlobalNotification />
<div id="modal" className="container"></div>
</div>
2015-05-18 18:00:12 +02:00
);
}
2015-05-20 12:00:16 +02:00
});
2015-05-13 16:26:12 +02:00
export default AscribeApp;