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

Commit 60f34ad

Browse files
just-boristimdorr
authored andcommitted
support history 3 (#476)
1 parent 91ba37b commit 60f34ad

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"eslint-config-rackt": "^1.1.1",
5757
"eslint-plugin-react": "^3.15.0",
5858
"expect": "^1.13.0",
59-
"history": "^2.0.0",
59+
"history": "^3.0.0",
6060
"isparta": "^4.0.0",
6161
"isparta-loader": "^2.0.0",
6262
"karma": "^0.13.3",
@@ -73,7 +73,7 @@
7373
"react": "^0.14.3",
7474
"react-dom": "^0.14.3",
7575
"react-redux": "^4.4.0",
76-
"react-router": "^2.0.0",
76+
"react-router": "^3.0.0",
7777
"redux": "^3.0.4",
7878
"redux-devtools": "^3.0.0",
7979
"redux-devtools-dock-monitor": "^1.0.1",

src/sync.js

+5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ export default function syncHistoryWithStore(history, store, {
9797
}
9898
unsubscribeFromHistory = history.listen(handleLocationChange)
9999

100+
// support history 3.x
101+
if(history.getCurrentLocation) {
102+
handleLocationChange(history.getCurrentLocation())
103+
}
104+
100105
// The enhanced history uses store as source of truth
101106
return {
102107
...history,

test/_createSyncTest.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ export default function createTests(createHistory, name, reset = defaultReset) {
183183

184184
syncHistoryWithStore(clientHistory, clientStore)
185185

186-
// We expect that we get a single call to history
187-
expect(historyListen.calls.length).toBe(1)
186+
// History v3: Listener should not be called during initialization
187+
expect(historyListen.calls.length).toBe(0)
188188

189189
clientStore.dispatch({
190190
type: 'non-router'
191191
})
192192

193-
// We expect that we still get only a single call to history after a non-router action is dispatched
194-
expect(historyListen.calls.length).toBe(1)
193+
// We expect that we still didn't get any call to history after a non-router action is dispatched
194+
expect(historyListen.calls.length).toBe(0)
195195

196196
historyUnsubscribe()
197197
})

0 commit comments

Comments
 (0)