Skip to content

Commit 04eae82

Browse files
authored
fix: route push problem with subscription in prod mode (#2234)
* fix: route push problem with subscription in prod mode * fix ci
1 parent 4d3ed5e commit 04eae82

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

packages/dva-core/test/effects.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ describe('effects', () => {
359359
effects: {
360360
addDelay: [
361361
function*({ payload }, { call, put }) {
362-
yield call(delay, 100);
362+
yield call(delay, 120);
363363
yield put({ type: 'add', payload });
364364
},
365365
{ type: 'throttle', ms: 100 },

packages/dva/src/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,22 @@ function render(container, store, app, router) {
105105
function patchHistory(history) {
106106
const oldListen = history.listen;
107107
history.listen = callback => {
108+
// TODO: refact this with modified ConnectedRouter
108109
// Let ConnectedRouter to sync history to store first
109110
// connected-react-router's version is locked since the check function may be broken
111+
// min version of connected-react-router
112+
// e.g.
113+
// function (e, t) {
114+
// var n = arguments.length > 2 && void 0 !== arguments[2] && arguments[2];
115+
// r.inTimeTravelling ? r.inTimeTravelling = !1 : a(e, t, n)
116+
// }
110117
// ref: https://github.com/umijs/umi/issues/2693
118+
const cbStr = callback.toString();
111119
const isConnectedRouterHandler =
112-
callback.name === 'handleLocationChange' &&
113-
callback.toString().indexOf('onLocationChanged') > -1;
120+
(callback.name === 'handleLocationChange' && cbStr.indexOf('onLocationChanged') > -1) ||
121+
(cbStr.indexOf('.inTimeTravelling') > -1 &&
122+
cbStr.indexOf('.inTimeTravelling') > -1 &&
123+
cbStr.indexOf('arguments[2]') > -1);
114124
callback(history.location, history.action);
115125
return oldListen.call(history, (...args) => {
116126
if (isConnectedRouterHandler) {

0 commit comments

Comments
 (0)