@@ -61,6 +61,8 @@ function locationsAreEqual(a, b) {
6161function syncReduxAndRouter ( history , store , selectRouterState = SELECT_STATE ) {
6262 const getRouterState = ( ) => selectRouterState ( store . getState ( ) ) ;
6363 let lastChangeId = 0 ;
64+ let firstRoute = undefined ;
65+ let lastRoute = { } ;
6466
6567 if ( ! getRouterState ( ) ) {
6668 throw new Error (
@@ -75,6 +77,11 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
7577 state : location . state
7678 } ;
7779
80+ if ( firstRoute === undefined ) {
81+ firstRoute = route ;
82+ }
83+ console . log ( 'HISTORY' , route ) ;
84+
7885 // Avoid dispatching an action if the store is already up-to-date,
7986 // even if `history` wouldn't do anything if the location is the same
8087 if ( locationsAreEqual ( getRouterState ( ) , route ) ) return ;
@@ -87,14 +94,22 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
8794 } ) ;
8895
8996 const unsubscribeStore = store . subscribe ( ( ) => {
90- const routing = getRouterState ( ) ;
97+ let routing = getRouterState ( ) ;
98+ console . log ( 'STORE' , routing ) ;
99+
100+ if ( routing === initialState ) {
101+ routing = firstRoute ;
102+ }
91103
92104 // Only update the router once per `pushPath` call. This is
93105 // indicated by the `changeId` state; when that number changes, we
94106 // should update the history.
95- if ( lastChangeId === routing . changeId ) return ;
107+ if ( lastChangeId === routing . changeId ) {
108+ if ( locationsAreEqual ( routing , lastRoute ) ) return ;
109+ }
96110
97111 lastChangeId = routing . changeId ;
112+ lastRoute = routing ;
98113
99114 const method = routing . replace ? 'replaceState' : 'pushState' ;
100115
0 commit comments