Skip to content

Commit e597e36

Browse files
committed
Small refactoring
1 parent 0a1c41e commit e597e36

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

modules/components/Routes.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,11 @@ var Routes = React.createClass({
245245
'inside some other component\'s render method'
246246
);
247247

248-
if (this._handleStateChange) {
249-
this._handleStateChange();
250-
delete this._handleStateChange;
251-
}
248+
this._handleStateChange();
252249
},
253250

254251
componentDidUpdate: function () {
255-
if (this._handleStateChange) {
256-
this._handleStateChange();
257-
delete this._handleStateChange;
258-
}
252+
this._handleStateChange();
259253
},
260254

261255
/**
@@ -295,19 +289,25 @@ var Routes = React.createClass({
295289
} else if (abortReason) {
296290
this.goBack();
297291
} else {
298-
this._handleStateChange = this.handleStateChange.bind(this, path, actionType, this.state.matches);
292+
this._nextStateChangeHandler = this._finishTransitionTo.bind(this, path, actionType, this.state.matches);
299293
this.setState(nextState);
300294
}
301295
});
302296
},
303297

304-
handleStateChange: function (path, actionType, previousMatches) {
298+
_handleStateChange: function () {
299+
if (this._nextStateChangeHandler) {
300+
this._nextStateChangeHandler();
301+
delete this._nextStateChangeHandler;
302+
}
303+
},
304+
305+
_finishTransitionTo: function (path, actionType, previousMatches) {
305306
var currentMatches = this.state.matches;
306307
updateMatchComponents(currentMatches, this.refs);
307308

308-
if (shouldUpdateScroll(currentMatches, previousMatches)) {
309+
if (shouldUpdateScroll(currentMatches, previousMatches))
309310
this.updateScroll(path, actionType);
310-
}
311311

312312
if (this.props.onChange)
313313
this.props.onChange.call(this);

0 commit comments

Comments
 (0)