Skip to content

Commit a2a9e37

Browse files
committed
Use shallowEqual to fix extraenous setPath() calls.
Fixes #177
1 parent 66d736b commit a2a9e37

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Diff for: lib/RouterMixin.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var invariant = require('./util/invariant');
55
var assign = Object.assign || require('object-assign');
66
var matchRoutes = require('./matchRoutes');
77
var Environment = require('./environment');
8+
var shallowEqual = require('is-equal-shallow');
89

910
var RouterMixin = {
1011
mixins: [Environment.Mixin],
@@ -39,8 +40,10 @@ var RouterMixin = {
3940
},
4041

4142
componentWillReceiveProps: function(nextProps) {
42-
var nextState = this.getRouterState(nextProps);
43-
this.delegateSetRoutingState(nextState);
43+
if (!shallowEqual(nextProps, this.props)) {
44+
var nextState = this.getRouterState(nextProps);
45+
this.delegateSetRoutingState(nextState);
46+
}
4447
},
4548

4649
getRouterState: function(props) {

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Declarative router component for React",
55
"main": "index.js",
66
"dependencies": {
7+
"is-equal-shallow": "^0.1.3",
78
"object-assign": "^4.1.0",
89
"object.omit": "^2.0.0",
910
"qs": "^6.2.0",
@@ -70,4 +71,4 @@
7071
"publishConfig": {
7172
"registry": "https://registry.npmjs.org"
7273
}
73-
}
74+
}

0 commit comments

Comments
 (0)