From 808669883f61e42a277c7728bcbe0bff0dab1f90 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Sat, 24 Jan 2015 14:45:52 -0800 Subject: [PATCH] Use constant instead of prop --- modules/RouteHandlerMixin.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/RouteHandlerMixin.js b/modules/RouteHandlerMixin.js index a5cbcee593..0c4f92d374 100644 --- a/modules/RouteHandlerMixin.js +++ b/modules/RouteHandlerMixin.js @@ -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: { @@ -19,12 +22,6 @@ var RouteHandlerMixin = { }; }, - getDefaultProps: function () { - return { - ref: '__routeHandler__' - }; - }, - componentDidMount: function () { this._updateRouteComponent(); }, @@ -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 () { @@ -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; } };