admin管理员组文章数量:1208155
I'm learning Reactjs, and I am rendering a simple page with some components. One of this components is this:
class Header extends React.Component {
render(){
return (
<header>
<div class="container">
<Logo />
<Navigation />
</div>
</header>
);
}
}
export default Header
I'm using Bootstrap CSS I want the div
inside the header to use the styles of container
, how ever, after build, the class is gone.
Is there a way to force the attribute class in the components?
I'm learning Reactjs, and I am rendering a simple page with some components. One of this components is this:
class Header extends React.Component {
render(){
return (
<header>
<div class="container">
<Logo />
<Navigation />
</div>
</header>
);
}
}
export default Header
I'm using Bootstrap CSS I want the div
inside the header to use the styles of container
, how ever, after build, the class is gone.
Is there a way to force the attribute class in the components?
Share Improve this question edited Jul 28, 2018 at 17:48 Zakaria Acharki 67.5k15 gold badges78 silver badges105 bronze badges asked Jan 30, 2016 at 15:45 PabloPablo 10.6k18 gold badges59 silver badges80 bronze badges1 Answer
Reset to default 28You have to use the className
attribute instead of the class
attribute, e.g :
class Header extends React.Component {
render() {
return (
<header>
<div className="container">
<Logo />
<Navigation />
</div>
</header>
);
}
}
Check the list of Supported Attributes in the documentation.
All attributes are camel-cased and the attributes
class
andfor
areclassName
andhtmlFor
, respectively, to match the DOM API specification.
本文标签: javascriptWhy is react removing my class namesStack Overflow
版权声明:本文标题:javascript - Why is react removing my class names? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738742538a2109933.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论