Skip to content

Instantly share code, notes, and snippets.

@choonkending
Created September 4, 2016 22:49
Show Gist options
  • Save choonkending/e87b8c772a4ed47c611dce1da170c441 to your computer and use it in GitHub Desktop.
Save choonkending/e87b8c772a4ed47c611dce1da170c441 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
class ConcreteToggle extends Component {
constructor(props) {
super(props);
this.state = { isActive: false };
this.onToggle = this.onToggle.bind(this);
}
render() {
return (
<div>
<p onClick={this.onToggle}>title</p>
{ this.state.isActive && <p>content</p> }
</div>
);
}
onToggle() {
this.setState({ isActive : !this.state.isActive });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment