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

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

Closed
heyuncoder opened this issue Mar 16, 2019 · 12 comments
Closed

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

heyuncoder opened this issue Mar 16, 2019 · 12 comments

Comments

@heyuncoder
Copy link

尝试使用 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
Copy link

zhnd commented Mar 16, 2019

I'm having the same problem.

@ghost
Copy link

ghost commented Mar 16, 2019

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

@RootAnt
Copy link

RootAnt commented Mar 16, 2019

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
Copy link

Any updates on this issue? :)

@csflyer
Copy link

csflyer commented Mar 17, 2019

I met the same problem

@csflyer
Copy link

csflyer commented Mar 17, 2019

solved following @ RootAnt

@kurisLei
Copy link

i met the same problem today:)

@hnsylitao
Copy link

@kurisLei me too

@kurisLei
Copy link

@kurisLei me too

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

@hanwenbo
Copy link

完了 跑不起来了 Consumer

@sorrycc
Copy link
Contributor

sorrycc commented Mar 18, 2019

参考 sorrycc/blog#82 ,别写死版本。。

@Barretemer
Copy link

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.

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

No branches or pull requests