Skip to content

Commit b9c0e5e

Browse files
author
Dan Mosedale
committed
Clean up hashHistory cruft
1 parent 53d2b45 commit b9c0e5e

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

content-src/components/Routes/Routes.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ const {connect} = require("react-redux");
44
const {actions} = require("common/action-manager");
55

66
// This stuff needs a DOM to work with
7+
let customHistory;
78
if (!PRERENDER) {
89
const {createHashHistory} = require("history");
9-
const history = useRouterHistory(createHashHistory)({queryKey: false});
10+
customHistory = useRouterHistory(createHashHistory)({queryKey: false});
1011
}
1112

1213
let isFirstLoad = true;
@@ -19,16 +20,12 @@ const RouteList = (
1920
<IndexRoute title="History" component={require("components/TimelinePage/TimelineHistory")} />
2021
<Route title="History" path="bookmarks" component={require("components/TimelinePage/TimelineBookmarks")} />
2122
</Route>
22-
</Route>
23-
);
23+
</Route>
24+
);
2425

2526
const Routes = React.createClass({
2627
componentDidMount() {
27-
if (PRERENDER) {
28-
return;
29-
}
30-
31-
this.unlisten = history.listen(location => {
28+
this.unlisten = customHistory.listen(location => {
3229
this.props.dispatch(actions.NotifyRouteChange(Object.assign({}, location, {isFirstLoad})));
3330
if (isFirstLoad) {
3431
isFirstLoad = false;
@@ -40,8 +37,12 @@ const Routes = React.createClass({
4037
this.unlisten();
4138
},
4239
render() {
40+
let routerProps = {};
41+
if (!PRERENDER) {
42+
routerProps.history = customHistory;
43+
}
4344
return (
44-
<Router>
45+
<Router {...routerProps}>
4546
{ RouteList }
4647
</Router>);
4748
}

0 commit comments

Comments
 (0)