diff --git a/src/common/Router/Router.js b/src/common/Router/Router.js index 9c14508e8..bf90c1c4c 100644 --- a/src/common/Router/Router.js +++ b/src/common/Router/Router.js @@ -6,10 +6,9 @@ class Router extends Component { constructor(props) { super(props); - this.historyLength = history.length; this.state = { views: Array.apply(null, { length: props.config.views.length }).map(() => ({ - id: -1, + path: null, element: null })) }; @@ -28,12 +27,10 @@ class Router extends Component { return nextState.views !== this.state.views; } - onLocationChanged = ({ timeStamp: id } = { timeStamp: 0 }) => { + onLocationChanged = () => { const hashIndex = window.location.href.indexOf('#'); const hashPath = hashIndex === -1 ? '' : window.location.href.substring(hashIndex + 1); const path = joinPaths('/', hashPath); - const isPushAction = this.historyLength < history.length; - this.historyLength = history.length; this.props.config.views.forEach((viewConfig, viewConfigIndex) => { viewConfig.routes.forEach((routeConfig) => { if (matchPath(path, routeConfig)) { @@ -41,18 +38,14 @@ class Router extends Component { views: views.map((view, viewIndex) => { if (viewIndex > viewConfigIndex) { return { - id: -1, + path: null, element: null }; } else if (viewIndex === viewConfigIndex) { - if (!isPushAction && React.isValidElement(view.element) && view.element.type === routeConfig.component) { - return view; - } else { - return { - id, - element: React.createElement(routeConfig.component) - }; - } + return { + path, + element: React.createElement(routeConfig.component) + }; } else { return view; } @@ -69,7 +62,7 @@ class Router extends Component { { this.state.views .filter(({ element }) => React.isValidElement(element)) - .map(({ id, element }) =>
{element}
) + .map(({ path, element }) =>
{element}
) } );