ant-design / ant-design-pro

👨🏻‍💻👩🏻‍💻 Use Ant Design like a Pro!
https://pro.ant.design
MIT License
36.34k stars 8.14k forks source link

🧐[问题] 退出跳转到登录页面useEffect问题 #9283

Closed binkuolo closed 2 years ago

binkuolo commented 2 years ago

🧐 问题描述

登录之后跳转到后台主页/Welecome, 在不刷新页面的情况下点击退出,跳转到/user/login ,登录页面组件的 hooks 生命周期 useEffect 会被触发两次,如果路由中的layout不为false就不会出现这种情况,但是我登录页面不需要layout布局,由于登录页面挂载就需要请求服务器获取二维码链接信息并开启定时器轮询获取用户的扫码结果,但是目前遇到登录后如果用户不刷新页面立马退出,登录页面就发起了两次请求并开启两个定时器,导致流量浪费!目前不知道是bug还是我的场景设计缺陷。

💻 示例代码:

antdpro版本:v5.0.0 路由部分: { path:"/user", layout: false, routes: [ { path: "/user/login", component: "@/pages/login/login", name: "商家登陆", }, { path: "/user/wechat/register", component: "@/pages/login/register", name: "微信扫码注册", }, { component: './404', }, ] },

🚑 其他信息

image

chenshuai2144 commented 2 years ago

我记得好像是重定向的问题。pathname变化了,所以组件销毁了。

你有兴趣来个小的repo帮我们重现一下吗?我这周解决一下

binkuolo commented 2 years ago

我不懂repo是什么😄,大佬可以科普一下吗

binkuolo commented 2 years ago

repo 复现仓库 代码在39行-49行

binkuolo commented 2 years ago

那我现在是需要升级什么呢?

chenshuai2144 commented 2 years ago

把依赖全部删除,重新安装即可

binkuolo commented 2 years ago

已经解决 谢谢

发自我的iPhone

------------------ 原始邮件 ------------------ 发件人: 陈帅 @.> 发送时间: 2021年11月14日 11:31 收件人: ant-design/ant-design-pro @.> 抄送: 冰阔乐 @.>, Author @.> 主题: Re: [ant-design/ant-design-pro] ��[问题] 退出跳转到登录页面useEffect问题 (Issue #9283)

把依赖全部删除,重新安装即可

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.