Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80551 views
1
import React from 'react/addons';
2
import { RouteHandler } from 'react-router';
3
import AppNav from './AppNav';
4
5
const { CSSTransitionGroup } = React.addons;
6
7
class AppHandler extends React.Component {
8
static willTransitionTo(transition) {
9
const { path } = transition;
10
11
if (path !== '/' && path.endsWith('/')) {
12
transition.redirect(path.substring(0, path.length - 1));
13
}
14
}
15
16
// Fetch all docs on start up, since there aren't that many
17
static async routerWillRun({ flux }) {
18
const docActions = flux.getActions('docs');
19
return await docActions.getAllDocs();
20
}
21
22
render() {
23
return (
24
<div>
25
<AppNav />
26
<CSSTransitionGroup transitionName="RouteTransition">
27
<RouteHandler {...this.props} key={this.props.pathname} />
28
</CSSTransitionGroup>
29
</div>
30
);
31
}
32
}
33
34
export default AppHandler;
35
36