Skip to content Skip to sidebar Skip to footer

Why Is React Removing My Class Names?

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 (

Solution 1:

You have to use the className attribute instead of the class attribute, e.g :

classHeaderextendsReact.Component {
    render() {
        return  (
            <header><divclassName="container"><Logo /><Navigation /></div></header>
        );
    }
}

Check the list of Supported Attributes in the documentation.

All attributes are camel-cased and the attributes class and for are className and htmlFor, respectively, to match the DOM API specification.

Post a Comment for "Why Is React Removing My Class Names?"