@@ -2,24 +2,11 @@ const deepEqual = require('deep-equal');
2
2
3
3
// Constants
4
4
5
- const INIT_PATH = "@@router/INIT_PATH" ;
6
5
const UPDATE_PATH = "@@router/UPDATE_PATH" ;
7
6
const SELECT_STATE = state => state . routing ;
8
7
9
8
// Action creators
10
9
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
-
23
10
function pushPath ( path , state , { avoidRouterUpdate = false } = { } ) {
24
11
return {
25
12
type : UPDATE_PATH ,
@@ -54,7 +41,7 @@ let initialState = {
54
41
} ;
55
42
56
43
function update ( state = initialState , { type, payload } ) {
57
- if ( type === INIT_PATH || type === UPDATE_PATH ) {
44
+ if ( type === UPDATE_PATH ) {
58
45
return Object . assign ( { } , state , {
59
46
path : payload . path ,
60
47
changeId : state . changeId + ( payload . avoidRouterUpdate ? 0 : 1 ) ,
@@ -118,7 +105,8 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
118
105
// trigger an unnecessary `pushState` on load
119
106
lastRoute = initialState ;
120
107
121
- store . dispatch ( initPath ( route . path , route . state ) ) ;
108
+ const method = location . action === 'REPLACE' ? replacePath : pushPath ;
109
+ store . dispatch ( method ( route . path , route . state , { avoidRouterUpdate : true } ) ) ;
122
110
} else if ( ! locationsAreEqual ( getRouterState ( ) , route ) ) {
123
111
// The above check avoids dispatching an action if the store is
124
112
// already up-to-date
0 commit comments