@@ -60,7 +60,7 @@ function locationsAreEqual(a, b) {
60
60
61
61
function syncReduxAndRouter ( history , store , selectRouterState = SELECT_STATE ) {
62
62
const getRouterState = ( ) => selectRouterState ( store . getState ( ) ) ;
63
- let lastChangeId = 0 ;
63
+ let lastRoute = { } ;
64
64
65
65
if ( ! getRouterState ( ) ) {
66
66
throw new Error (
@@ -74,11 +74,14 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
74
74
path : history . createPath ( location ) ,
75
75
state : location . state
76
76
} ;
77
+ console . log ( 'HISTORY' , route ) ;
77
78
78
79
// Avoid dispatching an action if the store is already up-to-date,
79
80
// even if `history` wouldn't do anything if the location is the same
80
81
if ( locationsAreEqual ( getRouterState ( ) , route ) ) return ;
81
82
83
+ lastRoute = route ;
84
+
82
85
const updatePath = location . action === 'REPLACE'
83
86
? replacePath
84
87
: pushPath ;
@@ -88,13 +91,14 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
88
91
89
92
const unsubscribeStore = store . subscribe ( ( ) => {
90
93
const routing = getRouterState ( ) ;
94
+ console . log ( 'STORE' , routing ) ;
91
95
92
96
// Only update the router once per `pushPath` call. This is
93
97
// indicated by the `changeId` state; when that number changes, we
94
98
// should update the history.
95
- if ( lastChangeId === routing . changeId ) return ;
99
+ if ( locationsAreEqual ( routing , lastRoute ) ) return ;
96
100
97
- lastChangeId = routing . changeId ;
101
+ lastRoute = routing ;
98
102
99
103
const method = routing . replace ? 'replaceState' : 'pushState' ;
100
104
0 commit comments