Skip to content

Instantly share code, notes, and snippets.

@timsgardner
Created June 14, 2016 17:59
Show Gist options
  • Save timsgardner/b524bd5b6ec02e5978f6a6d78a3e9b41 to your computer and use it in GitHub Desktop.
Save timsgardner/b524bd5b6ec02e5978f6a6d78a3e9b41 to your computer and use it in GitHub Desktop.
paragraph pile
var ParagraphPile = React.createClass(
{getInitialState: function(){
return({tog: false});
},
handleClick: function(e){
labeledLog('state', this.state);
e.preventDefault();
var tog2 = !(this.state.tog);
this.setState({tog: tog2});
},
render: function(){
labeledLog("props", this.props);
var colorName;
if(this.state.tog){
colorName = 'blue';
}else{
colorName = 'red';
}
return(
<div className="paragraphHolder"
onClick = {this.handleClick}>
<div className={colorName}>
{this.props.textData.map(function(td){
return(<p>{td}</p>);
}
)}
</div>
</div>
);
}}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment