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

汇总:react-router、history 更新引起的相关问题及解决方案 #82

Open
sorrycc opened this issue Mar 18, 2019 · 1 comment
Labels

Comments

@sorrycc
Copy link
Owner

sorrycc commented Mar 18, 2019

持续更新。

Cannot read property 'Consumer' of undefined

react-router@4.4 已被 unpublish,理论上不会再遇到这个问题,遇到的重装 node_modules 后再试。

原因

使用的 react-router 和 react-router-dom 版本不同,通常出现在 ant-design-pro 的用户中,因为 ant-design-pro 手动依赖了一个 react-router-dom@^4.3.1^ 前缀引让 npm/yarn 下载依赖时匹配到 react-router@4.4。

解决

方法一(别这么干)

修改 package.json 中 react-router-dom 的依赖为 4.3.1。能解决问题,但治标不治本,下次 umi 把 react-router 升级到 4.4,就又挂了。

方法二(推荐)

参考 ant-design-pro!3787 修复,删除 react-router-dom 依赖,路由功能全部走 umi。

Module not found: Can't resolve '@babel/runtime/helpers/...'

原因

history 发布了 4.9,而 roadhog 之前版本对于 @babel/runtime 的处理不恰当。

解决

方法一

新建 webpack.config.js,内容如下:

export default function(webpackConfig) {
  delete webpackConfig.resolve.alias['@babel/runtime'];
  return webpackConfig;
}

方法二

roadhog 依赖升级为 ^2.5.0-beta.4

@KirySen
Copy link

KirySen commented May 30, 2019

感谢

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

No branches or pull requests

2 participants