@@ -2,24 +2,9 @@ import deepEqual from 'deep-equal'
22
33// Constants
44
5- const INIT_PATH = '@@router/INIT_PATH'
65export const UPDATE_PATH = '@@router/UPDATE_PATH'
76const SELECT_STATE = state => state . routing
87
9- // Action creators
10-
11- function initPath ( path , state ) {
12- return {
13- type : INIT_PATH ,
14- payload : {
15- path : path ,
16- state : state ,
17- replace : false ,
18- avoidRouterUpdate : true
19- }
20- }
21- }
22-
238export function pushPath ( path , state , { avoidRouterUpdate = false } = { } ) {
249 return {
2510 type : UPDATE_PATH ,
@@ -54,7 +39,7 @@ let initialState = {
5439}
5540
5641function update ( state = initialState , { type, payload } ) {
57- if ( type === INIT_PATH || type === UPDATE_PATH ) {
42+ if ( type === UPDATE_PATH ) {
5843 return Object . assign ( { } , state , {
5944 path : payload . path ,
6045 changeId : state . changeId + ( payload . avoidRouterUpdate ? 0 : 1 ) ,
@@ -128,7 +113,8 @@ export function syncReduxAndRouter(history, store, selectRouterState = SELECT_ST
128113 // trigger an unnecessary `pushState` on load
129114 lastRoute = initialState
130115
131- store . dispatch ( initPath ( route . path , route . state ) )
116+ const method = location . action === 'REPLACE' ? replacePath : pushPath ;
117+ store . dispatch ( method ( route . path , route . state , { avoidRouterUpdate : true } ) ) ;
132118 } else if ( ! locationsAreEqual ( getRouterState ( ) , route ) ) {
133119 // The above check avoids dispatching an action if the store is
134120 // already up-to-date
0 commit comments