Ant-design-pro: 3月底v4.0.0 TS版🐛[BUG]request执行window.g_app,报错Cannot read property '_store' of undefined

Created on 3 Apr 2020  ·  4Comments  ·  Source: ant-design/ant-design-pro

🐛 bug 描述

如题

📷 复现步骤

和以往一样新建项目后,修改request.ts,判断status===401错误代码:
window.g_app._store.dispatch({ type: 'login/logout', });
运行出现401错误,截获报错:Cannot read property '_store' of undefined

🏞 期望结果

执行dispatch动作,回到登录页。

💻 复现代码

同上修改request.ts

© 版本信息

  • Ant Design Pro 版本: 4.0.0
  • umi 版本:3.0.14
  • 浏览器环境:chrome/edge
  • 开发环境 [mac OS]

🚑 其他信息

另外发现奇怪问题:突然request.ts中的errorHandler失效(不知怎么产生的),无法截获任何错误,只好又单独写了个interceptors来截获,错误现象同上。

🛑 bug

Most helpful comment

https://github.com/umijs/umi/issues/4099
import { getDvaApp } from 'umi';
使用 getDvaApp()._store.dispatch()

All 4 comments

umi @3 已经把 g_app._store 干掉了
不允许使用这种黑科技了

遇到同样的问题,umi-request的interceptor不能访问store,有什么替代的方案吗?

https://github.com/umijs/umi/issues/4099
import { getDvaApp } from 'umi';
使用 getDvaApp()._store.dispatch()

umi @3 已经把 g_app._store 干掉了
不允许使用这种黑科技了

那应该怎么使用呢????我想获取全局的dispatch

Was this page helpful?
0 / 5 - 0 ratings

Related issues

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

RichardStark picture RichardStark  ·  3Comments

suifan picture suifan  ·  3Comments

952425340 picture 952425340  ·  3Comments

yjz1004 picture yjz1004  ·  3Comments