reactjs - 失败的道具类型:ForwardRef(Button):道具类型`component`无效:React中带有材料ui的警告
问题描述
我有一个简单的 React 代码,只需从材料 ui 中放置一个按钮。但我得到了下一个警告:
Warning: Failed prop type: ForwardRef(Button): prop type `component` is invalid; it must be a function, usually from the `prop-types` package, but received `undefined`.
in ForwardRef(Button) (created by WithStyles(ForwardRef(Button)))
in WithStyles(ForwardRef(Button)) (at App.js:12)
如何解决?
我的完整代码:
import React from 'react';
import Button from '@material-ui/core/Button';
const App = props => {
return (
<div className="App">
<Button variant="contained" color="primary">
Hello World
</Button>
</div>
);
};
export default App;
UPD:我的 package.json 文件。乍一看,我不使用任何其他 prop-types 包
{
...
"dependencies": {
"@material-ui/core": "^4.4.2",
"@material-ui/icons": "^4.4.1",
"connected-react-router": "^6.5.2",
"history": "^4.10.1",
"react": "^16.9.0",
"react-cookie": "^4.0.1",
"react-dom": "^16.9.0",
"react-redux": "^7.1.1",
"react-router": "^5.0.1",
"react-router-dom": "^5.0.1",
"react-scripts": "3.1.1",
"redux": "^4.0.4",
"redux-saga": "^1.0.5"
},
"scripts": {
...
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
...
],
"development": [
....
]
}
解决方案
推荐阅读
- arrays - 反应插入/删除数组中的行问题未更新
- javascript - 测试 Animate.css 时 element.classList.addClass 不是函数
- amcharts - 在 amcharts4 中按所有日期时间而不是小时显示日期轴
- here-api - HERE API 是否提供 GSM 小区信息的三角测量?
- google-cloud-platform - 如何将 Google 存储中的多个 csv 上传(通过不同的机器)合并到一个最终文件中
- flutter - 如何使“项目:”等于 CarouselSlider 中的可变长度?
- python - 无法在数据集上运行 PCA
- java - 用于创建 X 框的 Java 循环和 If 条件
- symfony - Symfony 2 - 为什么 event.DEBUG 出现在 dev.log 中
- python - 如何在 python 3.7 中自动更新我的 cx_freeze 应用程序