我的控制台中出现此警告:index.js:2178警告:道具类型失败:道具data-target
在<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<body>
<nav class="navbar navbar-toggler-sm navbar-light bg-success">
<div class="navbar-header">
<button class="navbar-toggler navbar-toggler-right" data-toggle="collapse" data-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<a href="#" class="navbar-brand" style="color: white">management</a>
<div id="navbarNav" class="collapse navbar-collapse">
<ul class="navbar-nav" style="color: white">
<li class="nav-item1"><a class="nav-link active"> Dashboard</a></li>
<li class="nav-item2"><a class="nav-link">Ads</a></li>
<li class="nav-item3"><a class="nav-link">Users</a></li>
</ul>
</div>
</div>
</nav>
</body>
中标记为必需,但其值为classes
。
我已经检查并确保正确将类作为道具传递。我不确定此错误来自哪里。如何摆脱这个错误?
WithStyles(Grid)
答案 0 :(得分:1)
您的自定义类名为GridListings
,您导出了GridListings
(带有withStyles),但是您已经在Grid.propTypes上定义了propTypes:
Grid.propTypes = {
classes: PropTypes.object.isRequired
};
尝试将其更改为:
GridListings.propTypes = {
classes: PropTypes.object.isRequired
};
我的猜测是,您正在更改/修改Grid(@ material-ui组件)的propType,而不是自己的组件(GridListings)。