Created
September 21, 2016 08:55
-
-
Save choonkending/925018f17f899d2bcd9cf0fd63010abe to your computer and use it in GitHub Desktop.
An example of the evolution of a component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Start with building the component */ | |
import React from 'react'; | |
class Value extends React.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 }); | |
} | |
} | |
export default Value; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.