Created
February 17, 2016 16:50
-
-
Save biglovisa/025c42afb7bd4cc9153a to your computer and use it in GitHub Desktop.
react-code
This file contains 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
// 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> | |
) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🐼 👍