Skip to content

Instantly share code, notes, and snippets.

@biglovisa
Created February 17, 2016 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save biglovisa/025c42afb7bd4cc9153a to your computer and use it in GitHub Desktop.
Save biglovisa/025c42afb7bd4cc9153a to your computer and use it in GitHub Desktop.
react-code
// aka root component
var Dashboard = React.createClass({
getInitialState: function() {
return { headerIsActive: false }
},
onButtonClick: function() {
console.log('in DASHBOARD!!');
},
render() {
return (
<div>
<div>
<Header active={this.state.headerIsActive} />
</div>
<div>
<Body handleButtonClick={this.onButtonClick} />
</div>
</div>
)
}
});
var Header = React.createClass({
render() {
var baseClass = this.props.active ? 'very-active' : 'not-active';
console.log(this.props);
return (
<div className={baseClass} >
<h1>IDEAS ALL OVER THE PLACE</h1>
</div>
)
}
});
var Body = React.createClass({
handleClick: function() {
this.props.handleButtonClick();
},
render() {
return (
<div>
<button onClick={this.handleClick}>Change color</button>
</div>
)
}
});
@joshuajhun
Copy link

🐼 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment