Is it possible to set a className on custom react components? [duplicate]

You can, but you should propagate the prop to the inner component. If not, it doesn’t know about it.

class SimpleComponent extends React.Component
{
    render() { return <p className={this.props.className}>Some text</p> }
}

To make the CSS query you want to accomplish, then you should create the div inside your component.

class SimpleComponent extends React.Component
{
    render() { return <div className={this.props.className}><p>Some text</p></div> }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)