Skip to content

Commit e882a84

Browse files
committed
Reuse empty _query objects.
1 parent 5c8bf43 commit e882a84

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: lib/matchRoutes.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,15 @@ function Match(path, route, match, query) {
117117
this.path;
118118
}
119119

120+
const EMPTY_OBJECT = {}; // Maintains reference equality, useful for SCU
121+
Object.freeze && Object.freeze(EMPTY_OBJECT);
120122
Match.prototype.getProps = function() {
121123
if (!this.route) {
122124
throw new Error("React-router-component: No route matched! Did you define a NotFound route?");
123125
}
124126
var props = assign({}, this.route.props, this.match);
125127
// Querystring is assigned as _query.
126-
props._query = this.query || {};
128+
props._query = this.query || EMPTY_OBJECT;
127129

128130
// Delete props that shouldn't be passed to the handler.
129131
delete props.pattern;

0 commit comments

Comments
 (0)