Files
optolith-client/js/views/Router.js
T
Lukas Obermann e1927227bf Changed data objects to ES6 classes
Additionally changed folder structure to components and views
2016-11-14 00:18:09 +01:00

46 lines
1.1 KiB
JavaScript

import React, { Component } from 'react';
import Route from './Route';
import TabStore from '../stores/TabStore';
import TitleBar from './TitleBar';
import Wait from './Wait';
import WaitStore from '../stores/WaitStore';
class Router extends Component {
state = {
section: TabStore.getCurrentSID(),
tab: TabStore.getCurrentID(),
wait: WaitStore.getWaiting()
};
_updateTabStore = () => this.setState({ section: TabStore.getCurrentSID(), tab: TabStore.getCurrentID() });
_updateWaitStore = () => this.setState({ wait: WaitStore.getWaiting() });
componentDidMount() {
TabStore.addChangeListener(this._updateTabStore);
WaitStore.addChangeListener(this._updateWaitStore);
}
componentWillUnmount() {
TabStore.removeChangeListener(this._updateTabStore);
WaitStore.removeChangeListener(this._updateWaitStore);
}
render() {
const { section, tab, wait } = this.state;
return (
<div id="body">
<Wait show={wait} />
<main>
<TitleBar section={section} tab={tab} />
<Route id={tab} />
</main>
</div>
);
}
}
export default Router;