我有一个简单的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": [
....
]
}