Skip to content
This repository has been archived by the owner on Oct 26, 2018. It is now read-only.

Commit

Permalink
support history 3 (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
just-boris authored and timdorr committed Oct 25, 2016
1 parent 91ba37b commit 60f34ad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions src/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions test/_createSyncTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down

0 comments on commit 60f34ad

Please sign in to comment.