Skip to content
This repository was archived by the owner on Oct 26, 2018. It is now read-only.

Commit 9872fff

Browse files
committed
Remove INIT_PATH
1 parent 3545a3e commit 9872fff

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

src/index.js

+3-15
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,11 @@ const deepEqual = require('deep-equal');
22

33
// Constants
44

5-
const INIT_PATH = "@@router/INIT_PATH";
65
const UPDATE_PATH = "@@router/UPDATE_PATH";
76
const SELECT_STATE = state => state.routing;
87

98
// Action creators
109

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-
2310
function pushPath(path, state, { avoidRouterUpdate = false } = {}) {
2411
return {
2512
type: UPDATE_PATH,
@@ -54,7 +41,7 @@ let initialState = {
5441
};
5542

5643
function update(state=initialState, { type, payload }) {
57-
if(type === INIT_PATH || type === UPDATE_PATH) {
44+
if(type === UPDATE_PATH) {
5845
return Object.assign({}, state, {
5946
path: payload.path,
6047
changeId: state.changeId + (payload.avoidRouterUpdate ? 0 : 1),
@@ -118,7 +105,8 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
118105
// trigger an unnecessary `pushState` on load
119106
lastRoute = initialState;
120107

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 }));
122110
} else if(!locationsAreEqual(getRouterState(), route)) {
123111
// The above check avoids dispatching an action if the store is
124112
// already up-to-date

0 commit comments

Comments
 (0)