diff --git a/package.json b/package.json index 1abdfa0..0b4e8f6 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "eslint-config-rackt": "^1.1.1", "eslint-plugin-react": "^3.15.0", "expect": "^1.13.0", - "history": "^2.0.0", + "history": "^3.0.0", "isparta": "^4.0.0", "isparta-loader": "^2.0.0", "karma": "^0.13.3", @@ -73,7 +73,7 @@ "react": "^0.14.3", "react-dom": "^0.14.3", "react-redux": "^4.4.0", - "react-router": "^2.0.0", + "react-router": "^3.0.0", "redux": "^3.0.4", "redux-devtools": "^3.0.0", "redux-devtools-dock-monitor": "^1.0.1", diff --git a/src/sync.js b/src/sync.js index ce98560..fc8711d 100644 --- a/src/sync.js +++ b/src/sync.js @@ -97,6 +97,11 @@ export default function syncHistoryWithStore(history, store, { } unsubscribeFromHistory = history.listen(handleLocationChange) + // support history 3.x + if(history.getCurrentLocation) { + handleLocationChange(history.getCurrentLocation()) + } + // The enhanced history uses store as source of truth return { ...history, diff --git a/test/_createSyncTest.js b/test/_createSyncTest.js index ee4268a..210cedc 100644 --- a/test/_createSyncTest.js +++ b/test/_createSyncTest.js @@ -183,15 +183,15 @@ export default function createTests(createHistory, name, reset = defaultReset) { syncHistoryWithStore(clientHistory, clientStore) - // We expect that we get a single call to history - expect(historyListen.calls.length).toBe(1) + // History v3: Listener should not be called during initialization + expect(historyListen.calls.length).toBe(0) clientStore.dispatch({ type: 'non-router' }) - // We expect that we still get only a single call to history after a non-router action is dispatched - expect(historyListen.calls.length).toBe(1) + // We expect that we still didn't get any call to history after a non-router action is dispatched + expect(historyListen.calls.length).toBe(0) historyUnsubscribe() })