Ant-design-pro: 点击退出登陆,跳转到登陆页面,提示无法对已卸载的组件进行状态更新

Created on 12 Oct 2020  ·  7Comments  ·  Source: ant-design/ant-design-pro

错误提示信息如下:
Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
image

🛑 bug

Most helpful comment

@chenshuai2144 @Json314 请问一下这个问题解决了吗啊大神

目前这样解决,退出登陆,延迟跳转,/src/models/login.js
image
不是完美的解决方式

All 7 comments

可能有些数据没有更新完,要去排查一下到底是哪个逻辑导致的

可能有些数据没有更新完,要去排查一下到底是哪个逻辑导致的

不是数据没有更新的缘故。只要是由SecurityLayout布局变为其他(UserLayout或者自定义的404),都会出现此错误。如果将退出登陆的路由跳转延迟100ms执行,就不会有错误了。怀疑是SecurityLayout某个组件文件中,useEffect里面return的函数中,修改了state???找了半天还是没找到原因。请大神指点一二

@chenshuai2144 @Json314 请问一下这个问题解决了吗啊大神

@chenshuai2144 @Json314 请问一下这个问题解决了吗啊大神

目前这样解决,退出登陆,延迟跳转,/src/models/login.js
image
不是完美的解决方式

@Json314 确实不报错了,没办法,先凑合用吧,这个至少没有warning就很不错了,官方又不给予正确的答案

同问

看了看好像只能 setTimeOut 了

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yjz1004 picture yjz1004  ·  3Comments

happier2 picture happier2  ·  3Comments

Yoping picture Yoping  ·  3Comments

yaoleiroyal picture yaoleiroyal  ·  3Comments

2uncle-code picture 2uncle-code  ·  3Comments