ReactJS 16.4和Material UI 4.x的兼容性 [英] ReactJS 16.4 and Material UI 4.x compatibility
问题描述
我正在使用React 16.4.1和metrial-ui 4.1.1,当我尝试在本地运行它时,出现以下错误.
I am using React 16.4.1 and metrial-ui 4.1.1 and when i tried to run it locally i am getting the following Error.
TypeError: _react.default.memo is not a function
createSvgIcon
c:/apps/projects/app/node_modules/@material-ui/icons/utils/createSvgIcon.js:17
14 | var _SvgIcon = _interopRequireDefault(require("@material-ui/core/SvgIcon"));
我在Windows上本地拥有的node和npm版本是10.16.0和6.9.0
And the node and npm versions i have locally (on windows) are 10.16.0 and 6.9.0
当我使用Jenkins(在Linux上运行)在节点10.13.0和npm 6.9.1上构建相同的组件时,它运行良好.
When i build the same using Jenkins (running on linux) with node 10.13.0 and npm 6.9.1 it is running fine.
不确定为什么这样的次要版本不匹配会导致此问题.
Not sure why such a minor version mismatches are causing this issue.
谢谢卫星
推荐答案
Unfortunately, React.memo was released in react@16.6.0
source.
@ material-ui/core @ 4.0.0
(甚至在4.1.1之前)似乎需要 react@16.8.0
It appears that @material-ui/core@4.0.0
(even before 4.1.1) requires react@16.8.0
source.
对于它的价值,将您的React版本升级到最新版本应该没有太大困难.最大的痛点是如果您使用诸如 enzyme
之类的库(或其他试图与API奇偶校验保持一致的依赖项).您还需要更新它,并且它是伙伴关系.
For what it's worth, there shouldn't be much difficulty in upgrading your React version to even the latest version. The biggest pain point will be if you use a library like enzyme
(or other dependencies that try to keep up with exact API parity). You'd need to also update that and it's partnering dependencies.
这篇关于ReactJS 16.4和Material UI 4.x的兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!