quitting react router

This commit is contained in:
Eric Hulburd
2016-03-02 12:07:31 -06:00
parent d650baab6d
commit 5b218f6518
17 changed files with 164 additions and 186 deletions

View File

@@ -10,23 +10,26 @@ class HouseComponent extends React.Component {
constructor(props){
super(props);
this.renders = 0;
this.updates = 0;
}
get house(){
return this.props.location.state && this.props.location.state.house;
}
setParam(event){
var house_component = this,
house = house_component.context.house,
param = event.target.dataset.param,
value = event.target.dataset.value,
update = {}, route_helper;
update[param] = value;
route_helper = new RouteHelper(house, house_component.props, update);
if (route_helper.routeUpdated()){
route_helper.updateHouseState();
if (house_component.renders < 10){
house_component.context.router.push(route_helper.newRoute());
house_component.renders += 1;
}
}
route_helper = new RouteHelper(house_component.props, update);
if (route_helper.routeUpdated()) route_helper.updateRoute();
}
componentDidUpdate(){
this.updates += 1;
console.log(this.updates, ') HouseComponent#componentDidUpdate');
}
graphSelected(){
@@ -57,7 +60,6 @@ class HouseComponent extends React.Component {
};
HouseComponent.contextTypes = {
house: React.PropTypes.instanceOf(House),
router: React.PropTypes.object.isRequired
};

View File

@@ -31,16 +31,16 @@
type="button" class="btn btn-primary">Table</button>
</div>
<div rt-if="this.context.house">
<div rt-if="this.house">
<h4>Select dates:</h4>
<div class="btn-group">
<button
rt-repeat="year in this.context.house.years"
rt-repeat="year in this.house.years"
data-param="year"
data-value="{year}"
key="data-year-{year}"
class="btn-info btn btn-sm"
rt-class="{active: year == this.context.house.state.year}"
rt-class="{active: year == this.house.state.year}"
onClick="{this.setParam.bind(this)}">{year}</button>
</div>
</div><br/>