未捕获的TypeError:__WEBPACK_IMPORTED_MODULE_0_react ___ default.a.createContext不是React项目中的函数

时间:2019-09-17 22:08:02

标签: reactjs material-ui

我一直在使用MaterialUI进行React项目。 最初,我使用的是react-materialize软件包,它可以正常工作。

我安装@material-ui/core软件包以使用MaterialUI组件时,出现以下错误

Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_0_react___default.a.createContext is not a function
    at Object.<anonymous> (index.min.js:40786)
    at __webpack_require__ (index.min.js:660)
    at fn (index.min.js:86)
    at Object.<anonymous> (index.min.js:74914)
    at __webpack_require__ (index.min.js:660)
    at fn (index.min.js:86)
    at Object.<anonymous> (index.min.js:26652)
    at __webpack_require__ (index.min.js:660)
    at fn (index.min.js:86)
    at Object.<anonymous> (index.min.js:74393)
:8083/favicon.ico:1 Failed to load resource: the server responded with a status of 404 (Not Found)

我正在使用的包裹:

    "react": "^15.5.4",
    "react-animated-number": "^0.4.2",
    "react-chartjs": "^0.8.0",
    "react-dom": "^15.5.4",
    "react-leaflet": "^1.1.4",
    "react-materialize": "^1.0.4",
    "react-modal": "^1.7.7",
    "react-router-dom": "^4.0.0-beta.8",
    "react-table": "^5.6.0",
    "react-tap-event-plugin": "^2.0.1",
    "@material-ui/core": "^4.4.2",
    "@material-ui/icons": "^4.4.1",
    "babel-core": "^6.24.0",
    "babel-loader": "^6.4.1",
    "babel-plugin-add-module-exports": "^0.2.1",
    "babel-plugin-react-html-attrs": "^2.0.0",
    "babel-plugin-transform-class-properties": "^6.23.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-es2015": "^6.24.0",
    "babel-preset-react": "^6.23.0",

1 个答案:

答案 0 :(得分:0)

material-ui/core v4.4.2 packageReact 16.8.0声明为peerDependency

它使用React 16中引入的新Context API

您可以upgrade your React version to 16,也可以使用older context API使用material-ui/core版本的软件包。