Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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