diff --git a/modules/__tests__/Router-test.js b/modules/__tests__/Router-test.js
index 37e2c136bb..b951fa12cb 100644
--- a/modules/__tests__/Router-test.js
+++ b/modules/__tests__/Router-test.js
@@ -622,6 +622,73 @@ describe('Router', function () {
});
});
});
+
+ it('should be called when Handler is rendered multiple times on same route', function (done) {
+
+ var div = document.createElement('div');
+
+ var counter = 0;
+
+ var Foo = React.createClass({
+ statics: {
+ willTransitionFrom: function (transition, component) {
+ counter++;
+ }
+ },
+
+ render: function () {
+ return
Foo
;
+ }
+ });
+
+ var Bar = React.createClass({
+ statics: {
+ willTransitionFrom: function (transition, component) {
+ counter++;
+ }
+ },
+
+ render: function () {
+ return Bar
;
+ }
+ });
+ var routes = (
+
+
+
+
+ );
+
+ TestLocation.history = [ '/bar' ];
+
+ var steps = [];
+
+ steps.push(function () {
+ TestLocation.push('/foo');
+ });
+
+ steps.push(function () {
+ TestLocation.push('/bar');
+ });
+
+ steps.push(function () {
+ expect(counter).toEqual(2);
+ done();
+ });
+
+ Router.run(routes, TestLocation, function (Handler, state) {
+
+ // Calling render on the handler twice should be allowed
+ React.render(, div);
+
+ React.render(, div, function () {
+ setTimeout(function() {
+ steps.shift()();
+ }, 1);
+ });
+ });
+ });
+
});
});
diff --git a/modules/utils/createRouter.js b/modules/utils/createRouter.js
index 2109d21fa6..7c706c5e03 100644
--- a/modules/utils/createRouter.js
+++ b/modules/utils/createRouter.js
@@ -160,7 +160,6 @@ function createRouter(options) {
function updateState() {
state = nextState;
- nextState = {};
}
if (typeof location === 'string') {
@@ -376,6 +375,7 @@ function createRouter(options) {
if (error || transition.isAborted)
return callback.call(router, error, transition);
+ nextState = {};
nextState.path = path;
nextState.action = action;
nextState.pathname = pathname;