Showing posts with label React. Show all posts
Showing posts with label React. Show all posts

Thursday, December 14, 2017

React toggle Class Name on click

getInitialState: function() {
    return {
      myclass: "ravish"
    }
  },
  handleClick: function() {
var temp="ravish";
if( this.state.myclass=="ravish"){
  temp="ravish open"
}
this.setState({
      myclass: temp
    });


<div id="change button" className={this.state.myclass} onClick={this.handleClick} ></div>