Last active
August 29, 2015 14:21
-
-
Save squarepegsys/536f39829ec35443713f to your computer and use it in GitHub Desktop.
ReactJS Demo
This file contains hidden or 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
<div class="row"> | |
<div class="col-md-2"></div> | |
<div class="col-md-8"> | |
<div id="state-info"></div> | |
</div> | |
<div class="col-md-2"></div> | |
</div> |
This file contains hidden or 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
React.render( | |
<StateInfo/> | |
, | |
document.getElementById('state-info') | |
); |
This file contains hidden or 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
<div> | |
<hr/> | |
<div className="row"> | |
<div className="col-md-2"></div> | |
<div className="col-md-10"> | |
<h2>{state.name}</h2> | |
<hr/> | |
</div> | |
</div> | |
<div className="row"> | |
<div className="col-md-10"> | |
<StateInfoItem label="Abbreviation" value={state.abbreviation}/> | |
<StateInfoItem label="Capital" value={state.capital}/> | |
<StateInfoItem label="Largest City" value={state["most-populous-city"]}/> | |
</div> | |
</div> | |
<div className="row"> | |
<div className="col-md-5"> | |
{prevButton} | |
</div> | |
<div className="col-md-2"></div> | |
<div className="col-md-5"> | |
{nextButton} | |
</div> | |
</div> | |
</div> |
This file contains hidden or 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
getInitialState: function() { | |
return {"index": 0} | |
}, | |
handlePrev: function() { | |
this.setState({"index":this.state.index-1}); | |
}, | |
handleNext: function() { | |
this.setState({"index":this.state.index+1}); | |
}, |
This file contains hidden or 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 StateInfo = React.createClass({ | |
..... | |
}; |
This file contains hidden or 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 StateInfoItem = React.createClass({ | |
render: function() { | |
return ( | |
<dl className="dl-horizontal"> | |
<dt>{this.props.label}</dt> | |
<dd>{this.props.value}</dd> | |
</dl> | |
) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment