alitajs / alita

A React framework based on umi.
https://alitajs.com
MIT License
792 stars 87 forks source link

[BUG] plugin-maxtabs 在路由重定向时导致页面假死 #467

Closed fangzhengjin closed 1 year ago

fangzhengjin commented 1 year ago

有如下路由, 当访问/test时,会打开两个标签页,其中一个为空,另一个为/test/list同时会导致资源使用飙升,页面假死

{
    name: '一级菜单',
    path: 'test',
    routes: [
      { path: '/test', redirect: '/test/list' },
      {
        path: 'list',
        name: '列表页',
        component: 'xxxxxx',
      }
    ]
}
xiaohuoni commented 1 year ago

redirect 应该已经修过了,你看看你的安装版本是多少?

fangzhengjin commented 1 year ago

@alita/plugins: 3.2.1 @umijs/route-utils: 2.2.1 antd: 4.24.1

xiaohuoni commented 1 year ago

你可以看下这里 https://github.com/alitajs/alita/blob/master/examples/tabs/.umirc.ts#L25

fangzhengjin commented 1 year ago

似乎是因为keepalive: [/foo/]配置的原因? 因为我这边项目需要全局都开标签, 所以我配置的keepalive: [/./], 在这种配置下有办法忽略重定向路由吗? 按常理来说, redirect路由并没有component, 所以无论何时都不应该被缓存

xiaohuoni commented 1 year ago

@fangzhengjin 有简单的 复现 demo 吗,你看这里处理了。https://github.com/alitajs/alita/blob/67bddde75ed07812926d2793fb590314a4bafe25/packages/plugins/templates/keepalive/context.tpl#L113 不管配置是什么 redirect 都是跳过的

xiaohuoni commented 1 year ago

这个问题看起来已经修复了,有问题再 reopen

rongxingsun commented 1 year ago

只要redirect页面就卡死 Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.