Upgrade to React Router v4 (#667)

* Upgrade to React Router v4

* Fix pages not change when the URL was changed.

This issue is due to the Redux `connect` wrapper around `<App/>`.
`connect` diffs changes in regular props to know when to update the
component, but doesn't check context props like `location`.
See
https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/blocked-updates.md.

* Update to new `history` methods.
This commit is contained in:
Caleb
2017-10-12 19:10:43 -06:00
committed by Shawn Erquhart
parent b0bf60bd7d
commit dbe96d33f9
11 changed files with 92 additions and 109 deletions

View File

@ -1,14 +1,5 @@
import { createHashHistory } from 'history';
import { useRouterHistory } from 'react-router';
import { syncHistoryWithStore } from 'react-router-redux';
import createHistory from 'history/createHashHistory';
let history = useRouterHistory(createHashHistory)({
queryKey: false
});
let history = createHistory();
const syncHistory = (store) => {
history = syncHistoryWithStore(history, store);
};
export { syncHistory };
export default history;

View File

@ -1,35 +0,0 @@
import React from 'react';
import { Route, IndexRoute } from 'react-router';
import App from '../containers/App';
import DashboardPage from '../containers/DashboardPage';
import CollectionPage from '../containers/CollectionPage';
import EntryPage from '../containers/EntryPage';
import SearchPage from '../containers/SearchPage';
import NotFoundPage from '../containers/NotFoundPage';
export default (
<Route path="/" component={App}>
<IndexRoute component={DashboardPage} />
<Route
path="/collections/:name"
component={CollectionPage}
/>
<Route
path="/collections/:name/entries/new"
component={EntryPage}
newRecord
/>
<Route
path="/collections/:name/entries/:slug"
component={EntryPage}
/>
<Route
path="/search/:searchTerm"
component={SearchPage}
/>
<Route
path="*"
component={NotFoundPage}
/>
</Route>
);