score:4

Accepted answer
export class XYZ extends Component{

    constructor(props){
        super(props);
    }

    renderClassNames(){
        let classname = "slide-tourInfo";

        if (this.props.readMore) {
            classname += " slide-tourInfo-scale";
        }

        return classname;
    }

    render(){
        return(
            <div className = {this.renderClassNames()}>

            </div>
        )
    }
}

score:1

   export default class MyClass extends Component{

        constructor(props){
            super(props);

            this.state {
                toggleClass: false
            }
        }

        toggleFunction = () => {
            this.setState({toggleClass: !this.state.toggleClass})
        }

        render(){
            return(
                <div>
                    <button onClick={this.toggleFunction}>ClickMe</button>
                    <div className={this.state.toggleClass?'classOnTrue':'classOnFalse'}></div>
                </div>
            )
        }
    }

Related Query

More Query from same tag