gpt4 book ai didi

javascript - 使用 material-ui 时出现 proptypes 错误

转载 作者:行者123 更新时间:2023-11-30 20:53:06 25 4
gpt4 key购买 nike

我刚开始一个 reactJS 项目,当我决定使用 material-ui 时,它开始抛出很多这样的错误:

bundle.js:12441 Warning: Failed Context Types: Calling PropTypes validators directly is not supported by the prop-types package. Use PropTypes.checkPropTypes() to call them. Read more at fb.me/use-check-prop-types Check the render method of CardHeader.

我的 App 组件如下所示:

import React from 'react';
import PropTypes from 'prop-types';
import NavBar from './common/NavBar';
import Logo from './common/Logo';
import MuiThemeProvider from 'material-ui/styles/MuithemeProvider';

class App extends React.Component {
render() {
return (
<MuiThemeProvider>
<div className="container-fluid">
<Logo />
<NavBar />
{this.props.children}
</div>
</MuiThemeProvider>
);
}
}

App.PropTypes = {
children: PropTypes.object.isRequired
};

export default App;

material-ui version: 0.20.0

react version: 15.0.2

最佳答案

尝试:

App.propTypes = {
children: PropTypes.object.isRequired
};

关于javascript - 使用 material-ui 时出现 proptypes 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47956980/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com