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

Commit 2ed7ad8

Browse files
committed
Remove INIT_PATH
1 parent d2b2d3c commit 2ed7ad8

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

src/index.js

Lines changed: 5 additions & 17 deletions
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'
6-
const UPDATE_PATH = '@@router/UPDATE_PATH'
7-
const SELECT_STATE = state => state.routing
5+
const UPDATE_PATH = "@@router/UPDATE_PATH";
6+
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),
@@ -128,7 +115,8 @@ function syncReduxAndRouter(history, store, selectRouterState = SELECT_STATE) {
128115
// trigger an unnecessary `pushState` on load
129116
lastRoute = initialState
130117

131-
store.dispatch(initPath(route.path, route.state))
118+
const method = location.action === 'REPLACE' ? replacePath : pushPath;
119+
store.dispatch(method(route.path, route.state, { avoidRouterUpdate: true }));
132120
} else if(!locationsAreEqual(getRouterState(), route)) {
133121
// The above check avoids dispatching an action if the store is
134122
// already up-to-date

0 commit comments

Comments
 (0)