ant-design / ant-design-pro

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

Uncaught TypeError: Cannot read property 'Consumer' of undefined #3765

Closed heyuncoder closed 5 years ago

heyuncoder commented 5 years ago

尝试使用 ant-design-pro,按照教程clone下来后,安装后启动,页面loading闪现一下之后一直白屏。打开console,显示错误: Uncaught TypeError: Cannot read property 'Consumer' of undefined

本机环境: Mac pro:10.14.3 node:8.11.3 npm:5.6.0

运行结果与错误如下:

my-project git:(master) npm start

> ant-design-pro@2.2.1 start /Users/sunny/Documents/practice/my-project
> cross-env APP_TYPE=site umi dev

Warning: Please use `require("react-router").matchPath` instead of `require("react-router/matchPath")`. Support for the latter will be removed in the next major release.
Warning: Please use `require("react-router").Router` instead of `require("react-router/Router")`. Support for the latter will be removed in the next major release.
Warning: Please use `require("react-router").Switch` instead of `require("react-router/Switch")`. Support for the latter will be removed in the next major release.
Warning: Please use `require("react-router").Route` instead of `require("react-router/Route")`. Support for the latter will be removed in the next major release.

✔ Webpack
  Compiled successfully in 8.86s

 WARNING  Compiled with 1 warnings                                                                                                                13:44:24

 warning  in ./node_modules/react-router-dom/esm/react-router-dom.js

"export '__RouterContext' was not found in 'react-router'

File sizes after gzip:

  2.01 MB  umi-dlls/umi.dll.js

The bundle size is significantly larger than recommended.
Consider reducing it with code splitting: https://goo.gl/9VhYWB
You can also analyze the project dependencies: https://goo.gl/LeUzfb

[umi-plugin-dll] Build dll done
? message Probably:
  nginx: master process /usr/local/opt/nginx/bin/nginx -g daemon off;   (pid 2171)
  in /usr/local

Would you like to run the app on another port instead? Yes
(node:13369) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
Starting the development server...

✔ Webpack
  Compiled successfully in 25.66s

Theme generated successfully
 DONE  Compiled successfully in 26055ms                                                                                                           13:44:58

  App running at:
  - Local:   http://localhost:8001/ (copied to clipboard)
  - Network: http://192.168.31.71:8001/
Uncaught TypeError: Cannot read property 'Consumer' of undefined
    at Link.render (react-router-dom.js:148)
    at finishClassComponent (react-dom.development.js:14695)
    at updateClassComponent (react-dom.development.js:14650)
    at beginWork (react-dom.development.js:15598)
    at performUnitOfWork (react-dom.development.js:19266)
    at workLoop (react-dom.development.js:19306)
    at HTMLUnknownElement.callCallback (react-dom.development.js:149)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:199)
    at invokeGuardedCallback (react-dom.development.js:256)
    at replayUnitOfWork (react-dom.development.js:18532)
    at renderRoot (react-dom.development.js:19422)
    at performWorkOnRoot (react-dom.development.js:20296)
    at performWork (react-dom.development.js:20208)
    at performSyncWork (react-dom.development.js:20182)
    at requestWork (react-dom.development.js:20051)
    at scheduleWork (react-dom.development.js:19865)
    at Object.enqueueSetState (react-dom.development.js:11144)
    at DynamicComponent.umi../node_modules/react/cjs/react.development.js.Component.setState (react.development.js:335)
    at dynamic.js:91
zhnd commented 5 years ago

I'm having the same problem.

ghost commented 5 years ago

刚刚试了试,安装上的 react-router-dom 为 4.4.0 安装了 4.3.1 是可以正常运行的

RootAnt commented 5 years ago

Same issue. Like the react-router-dom has published 4.4.0

First, delete the symbol '^' of "react-router-dom": "^4.3.1" from package.json. Then, remove the package-lock.json and node_modules/ directory. Run npm install again.

jiangwalle commented 5 years ago

Any updates on this issue? :)

csflyer commented 5 years ago

I met the same problem

csflyer commented 5 years ago

solved following @ RootAnt

kurisLei commented 5 years ago

i met the same problem today:)

hnsylitao commented 5 years ago

@kurisLei me too

kurisLei commented 5 years ago

@kurisLei me too

You can try to reduce the "react-route-dom" version in the package configuration file to below 4.4.0.

hanwenbo commented 5 years ago

完了 跑不起来了 Consumer

sorrycc commented 5 years ago

参考 https://github.com/sorrycc/blog/issues/82 ,别写死版本。。

Barretemer commented 4 years ago

Same issue. Like the react-router-dom has published 4.4.0

First, delete the symbol '^' of "react-router-dom": "^4.3.1" from package.json. Then, remove the package-lock.json and node_modules/ directory. Run npm install again.

Problem solved! Thanks a lot.