class Test extends React.Component{
constructor(){
super();
this.state = {toggle:false}
this.updateToggle = this.updateToggle.bind(this);
}
updateToggle(flag){
this.setState({toggle:flag});
}
render(){
return(
<div>
<button onClick={()=>this.updateToggle(!this.state.toggle)}>button</button>
<p>{this.state.toggle ? "on" : "off" }</p>
</div>
)
}
}