Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: route push problem with subscription in prod mode #2234

Merged
merged 2 commits into from
Nov 1, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: route push problem with subscription in prod mode
  • Loading branch information
sorrycc committed Nov 1, 2019
commit c2cf3046cda848042c4c2f71015b6649d748d554
14 changes: 12 additions & 2 deletions packages/dva/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,22 @@ function render(container, store, app, router) {
function patchHistory(history) {
const oldListen = history.listen;
history.listen = callback => {
// TODO: refact this with modified ConnectedRouter
// Let ConnectedRouter to sync history to store first
// connected-react-router's version is locked since the check function may be broken
// min version of connected-react-router
// e.g.
// function (e, t) {
// var n = arguments.length > 2 && void 0 !== arguments[2] && arguments[2];
// r.inTimeTravelling ? r.inTimeTravelling = !1 : a(e, t, n)
// }
// ref: https://github.com/umijs/umi/issues/2693
const cbStr = callback.toString();
const isConnectedRouterHandler =
callback.name === 'handleLocationChange' &&
callback.toString().indexOf('onLocationChanged') > -1;
(callback.name === 'handleLocationChange' && cbStr.indexOf('onLocationChanged') > -1) ||
(cbStr.indexOf('.inTimeTravelling') > -1 &&
cbStr.indexOf('.inTimeTravelling') > -1 &&
cbStr.indexOf('arguments[2]') > -1);
callback(history.location, history.action);
return oldListen.call(history, (...args) => {
if (isConnectedRouterHandler) {
Expand Down