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

Support history 3 #476

Merged
merged 1 commit into from
Oct 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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