Closed lorenwe closed 6 months ago
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.
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.
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, }, }
配置文件 配置的是 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 就一切正常了
keepalive: [/./],
keepalive: ['/system/menu-management', '/system/internationalization'],
由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。
使用这个属性是有一定风险的( See https://github.com/umijs/umi/issues/12170#issuecomment-2067962671 )。
如有问题,给一个最小复现的仓库看看吧。
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)
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