尝试使用 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
> [email protected] 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
I'm having the same problem.
刚刚试了试,安装上的 react-router-dom 为 4.4.0
安装了 4.3.1 是可以正常运行的
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.
Any updates on this issue? :)
I met the same problem
solved following @ RootAnt
i met the same problem today:)
@kurisLei me too
@kurisLei me too
You can try to reduce the "react-route-dom" version in the package configuration file to below 4.4.0.
完了 跑不起来了 Consumer
参考 https://github.com/sorrycc/blog/issues/82 ,别写死版本。。
Same issue. Like the react-router-dom has published 4.4.0
First, delete the symbol '^' of
"react-router-dom": "^4.3.1"frompackage.json.
Then, remove thepackage-lock.jsonandnode_modules/directory.
Runnpm installagain.
Problem solved! Thanks a lot.
Most helpful comment
Same issue. Like the react-router-dom has published 4.4.0
First, delete the symbol '^' of
"react-router-dom": "^4.3.1"frompackage.json.Then, remove the
package-lock.jsonandnode_modules/directory.Run
npm installagain.