Skip to content

Commit

Permalink
Use constant instead of prop
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Jan 25, 2015
1 parent fe5ec39 commit 8086698
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions modules/RouteHandlerMixin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
var React = require('react');
var assign = require('react/lib/Object.assign');
var PropTypes = require('./PropTypes');

var REF_NAME = '__routeHandler__';

var RouteHandlerMixin = {

contextTypes: {
Expand All @@ -19,12 +22,6 @@ var RouteHandlerMixin = {
};
},

getDefaultProps: function () {
return {
ref: '__routeHandler__'
};
},

componentDidMount: function () {
this._updateRouteComponent();
},
Expand All @@ -34,7 +31,7 @@ var RouteHandlerMixin = {
},

_updateRouteComponent: function () {
this.context.setRouteComponentAtDepth(this.getRouteDepth(), this.refs[this.props.ref]);
this.context.setRouteComponentAtDepth(this.getRouteDepth(), this.refs[REF_NAME]);
},

getRouteDepth: function () {
Expand All @@ -43,7 +40,7 @@ var RouteHandlerMixin = {

createChildRouteHandler: function (props) {
var route = this.context.getRouteAtDepth(this.getRouteDepth());
return route ? React.createElement(route.handler, props || this.props) : null;
return route ? React.createElement(route.handler, assign({}, props || this.props, { ref: REF_NAME })) : null;
}

};
Expand Down

0 comments on commit 8086698

Please sign in to comment.