Skip to content

Commit fb87b23

Browse files
committed
Revert "Revert "Revert "[removed] "static" <Route> props"""
This reverts commit 53bc0fb.
1 parent 2614dd4 commit fb87b23

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

modules/components/Route.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
var React = require('react');
2+
var withoutProperties = require('../utils/withoutProperties');
3+
4+
/**
5+
* A map of <Route> component props that are reserved for use by the
6+
* router and/or React. All other props are considered "static" and
7+
* are passed through to the route handler.
8+
*/
9+
var RESERVED_PROPS = {
10+
handler: true,
11+
path: true,
12+
defaultRoute: true,
13+
notFoundRoute: true,
14+
paramNames: true,
15+
children: true // ReactChildren
16+
};
217

318
/**
419
* <Route> components specify components that are rendered to the page when the
@@ -49,9 +64,16 @@ var Route = React.createClass({
4964

5065
displayName: 'Route',
5166

67+
statics: {
68+
69+
getUnreservedProps: function (props) {
70+
return withoutProperties(props, RESERVED_PROPS);
71+
}
72+
73+
},
74+
5275
propTypes: {
5376
handler: React.PropTypes.any.isRequired,
54-
getAsyncProps: React.PropTypes.func,
5577
path: React.PropTypes.string,
5678
name: React.PropTypes.string,
5779
ignoreScrollBehavior: React.PropTypes.bool

modules/components/Routes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ var Routes = React.createClass({
400400
reversedArray(matches).forEach(function (match) {
401401
var route = match.route;
402402

403-
props = {};
403+
props = Route.getUnreservedProps(route.props);
404404

405405
props.ref = '__activeRoute__';
406406
props.params = match.params;

modules/utils/withoutProperties.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function withoutProperties(object, properties) {
2+
var result = {};
3+
4+
for (var property in object) {
5+
if (object.hasOwnProperty(property) && !properties[property])
6+
result[property] = object[property];
7+
}
8+
9+
return result;
10+
}
11+
12+
module.exports = withoutProperties;

0 commit comments

Comments
 (0)