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

[Bug] 关于 umi max 开启 keepalive 后,路由重定向不能正常工作的问题 #12333

Closed
lorenwe opened this issue Apr 26, 2024 · 2 comments

Comments

@lorenwe
Copy link

lorenwe commented Apr 26, 2024

What happens?

umi max 开启 keepalive 后,路由重定向会出现异常,会报错 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.

Mini Showcase Repository(REQUIRED)

Please provide a minimal reproduction then upload to your GitHub. 请提供 最小重现,并上传到你的 GitHub 仓库

// router.ts
const routes = [
    {
      name: 'Login',
      path: '/login',
      component: './Login',
      layout: false,
      exact: true,
    },
    {
      path: '/',
      redirect: '/dashboard',
    },
    {
      name: 'dashboard',
      path: '/dashboard',
      component: './Dashboard',
      exact: true,
    },
    {
    path: '/system',
    name: 'system',
    routes: [
      {
        path: '/system',
        redirect: '/system/menu-management',
      },
      {
        path: '/system/menu-management',
        name: 'menu-management',
        component: './System/MenuManagement',
        exact: true,
      },
      {
        path: '/system/internationalization',
        name: 'internationalization',
        component: './System/Internationalization',
        exact: true,
      },
    ]
  }
]
// config.ts
export default defineConfig({
  favicons: ['/favicon.ico'],
  // 多tab标签页支持
  plugins: [
    require.resolve('@alita/plugins/dist/keepalive'),
    require.resolve('@alita/plugins/dist/tabs-layout'),
  ],
  keepalive: [/./], // 这个设置会导致以上问题
  //keepalive: ['/system/menu-management', '/system/internationalization'],
  tabsLayout: {
    hasCustomTabs: true,
    hasDropdown: true,
  },
}

How To Reproduce

配置文件 配置的是 keepalive: [/./],
path: /system 设置了 redirect 跳转到 /system/menu-management,当我直接从地址栏输入 域名/system 回车时,页面就不能正常显示了,出现上面提到的报错,经过我不断的测试,发现是 keepalive 配置的问题 ,当我关闭掉 keepalive 时,就能正常直接访问 /system,进而自动跳转到 /system/menu-management, 但关闭 keepalive 后无法实现多 tabs 功能,当我照常开启 ,但 config.ts 文件配置 keepalive: ['/system/menu-management', '/system/internationalization'], 时,这时访问 /system 就一切正常了

Context

  • Umi Version: "@umijs/max": "^4.1.2",
  • Node Version:
  • Platform:
Copy link

由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
@lorenwe lorenwe changed the title [Bug] say something [Bug] 关于 umi max 开启 keepalive 后,路由重定向不能正常工作的问题 Apr 26, 2024
@fz6m
Copy link
Member

fz6m commented Apr 27, 2024

使用这个属性是有一定风险的( See #12170 (comment) )。

如有问题,给一个最小复现的仓库看看吧。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants