umijs / qiankun

📦 🚀 Blazing fast, simple and complete solution for micro frontends.
https://qiankun.umijs.org
MIT License
15.58k stars 2k forks source link

路由跳转后立即触发页面的react-router 的history.block #2953

Closed queentvxq closed 2 months ago

queentvxq commented 2 months ago

What happens?

使用qiankun后路由跳转会立即触发页面的react-router 的history.block

Mini Showcase Repository(REQUIRED)

因为single-spa的popstate触发机制,导致history.pushState跳转路由时触发popstate,从而触发history.block

function patchedUpdateState(updateState, methodName) { return function () { var urlBefore = window.location.href; var result = updateState.apply(this, arguments); var urlAfter = window.location.href;

if (!urlRerouteOnly || urlBefore !== urlAfter) {
  if (isStarted()) {
    // fire an artificial popstate event once single-spa is started,
    // so that single-spa applications know about routing that
    // occurs in a different application
    window.dispatchEvent(createPopStateEvent(window.history.state, methodName));
  } else {
    // do not fire an artificial popstate event before single-spa is started,
    // since no single-spa applications need to know about routing events
    // outside of their own router.
    reroute([]);
  }
}

return result;

}; }

How To Reproduce

Steps to reproduce the behavior: 1. 2.

Expected behavior 1. 2.

Context

github-actions[bot] commented 2 months ago

由于缺乏足够的信息(github、stackblitz、codesandbox等可复现仓库),我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。如果只是单独的技术咨询,可移步 https://qiankun.umijs.org/#-community 交流~