Skip to content

Commit a0d6945

Browse files
committed
Fix avoidRouterUpdate bug
1 parent b7f10aa commit a0d6945

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,25 @@ const SELECT_STATE = state => state.routing;
77

88
// Action creator
99

10-
function pushPath(path, state, avoidRouterUpdate) {
10+
function pushPath(path, state, opts) {
11+
opts = opts || {};
1112
return {
1213
type: UPDATE_PATH,
1314
path: path,
1415
state: state,
1516
replace: false,
16-
avoidRouterUpdate: !!avoidRouterUpdate
17+
avoidRouterUpdate: !!opts.avoidRouterUpdate
1718
};
1819
}
1920

20-
function replacePath(path, state, avoidRouterUpdate) {
21+
function replacePath(path, state, opts) {
22+
opts = opts || {};
2123
return {
2224
type: UPDATE_PATH,
2325
path: path,
2426
state: state,
2527
replace: true,
26-
avoidRouterUpdate: !!avoidRouterUpdate
28+
avoidRouterUpdate: !!opts.avoidRouterUpdate
2729
}
2830
}
2931

test/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ describe('replacePath', () => {
4949
replace: true,
5050
avoidRouterUpdate: true
5151
});
52+
53+
expect(replacePath('/foo', undefined, { avoidRouterUpdate: false })).toEqual({
54+
type: UPDATE_PATH,
55+
path: '/foo',
56+
state: undefined,
57+
replace: true,
58+
avoidRouterUpdate: false
59+
});
5260
});
5361
});
5462

0 commit comments

Comments
 (0)