Skip to content

Commit ef42b0f

Browse files
committed
Get devtools working
1 parent ff0f82c commit ef42b0f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function locationsAreEqual(a, b) {
6060

6161
function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
6262
const getRouterState = () => selectRouterState(store.getState());
63-
let lastChangeId = 0;
63+
let lastRoute = {};
6464

6565
if(!getRouterState()) {
6666
throw new Error(
@@ -74,11 +74,14 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
7474
path: history.createPath(location),
7575
state: location.state
7676
};
77+
console.log('HISTORY', route);
7778

7879
// Avoid dispatching an action if the store is already up-to-date,
7980
// even if `history` wouldn't do anything if the location is the same
8081
if(locationsAreEqual(getRouterState(), route)) return;
8182

83+
lastRoute = route;
84+
8285
const updatePath = location.action === 'REPLACE'
8386
? replacePath
8487
: pushPath;
@@ -88,13 +91,14 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
8891

8992
const unsubscribeStore = store.subscribe(() => {
9093
const routing = getRouterState();
94+
console.log('STORE', routing);
9195

9296
// Only update the router once per `pushPath` call. This is
9397
// indicated by the `changeId` state; when that number changes, we
9498
// should update the history.
95-
if(lastChangeId === routing.changeId) return;
99+
if(locationsAreEqual(routing, lastRoute)) return;
96100

97-
lastChangeId = routing.changeId;
101+
lastRoute = routing;
98102

99103
const method = routing.replace ? 'replaceState' : 'pushState';
100104

0 commit comments

Comments
 (0)