Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kbk0125
Created October 3, 2016 03:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbk0125/68522cd3516e6e33ec949c2669eebe10 to your computer and use it in GitHub Desktop.
Save kbk0125/68522cd3516e6e33ec949c2669eebe10 to your computer and use it in GitHub Desktop.
var vadersEmpire = React.createClass({
getInitialState: function() {
return {
rebelLocation: ''
};
},
reportRebelLocation: function(newLocation){
this.setState({
rebelLocation: newLocation
});
},
render: function() {
return (
<div>
<ImperialArmy
rebelLocation={this.state.rebelLocation}
updateLocation={this.reportRebelLocation}
/>
<ImperialNavy />
<MilitaryIntel />
</div>
);
}
});
var ImperialArmy = React.createClass({
render: function() {
return (
<StormTrooper
rebelLocation={this.props.rebelLocation}
updateLocation={this.props.updateLocation}
/>
<ATAT />
<ATST />
);
}
});
var StormTrooper = React.createClass({
discoverLocation: function(){
this.props.updateLocation(
this.refs.secretBaseLocation.value
);
},
render: function() {
return (
<input
placeholder = {this.props.rebelLocation}
value = ''
onChange = {this.discoverLocation}
ref="secretBaseLocation"
/>
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment