Created
October 3, 2016 03:03
-
-
Save kbk0125/68522cd3516e6e33ec949c2669eebe10 to your computer and use it in GitHub Desktop.
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
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