Skip to content

Commit 6b70f85

Browse files
committed
Update component refs in a more sensible place
1 parent c7ca87e commit 6b70f85

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

modules/components/Routes.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ function hasMatch(matches, match) {
7070
});
7171
}
7272

73-
function updateMatchComponents(matches, refs) {
74-
var i = 0, component;
75-
while (component = refs.__activeRoute__) {
76-
matches[i++].component = component;
77-
refs = component.refs;
78-
}
79-
}
80-
8173
/**
8274
* Computes the next state for the given component and calls
8375
* callback(error, nextState) when finished. Also runs all
@@ -101,8 +93,6 @@ function computeNextState(component, transition, callback) {
10193

10294
var fromMatches, toMatches;
10395
if (currentMatches.length) {
104-
updateMatchComponents(currentMatches, component.refs);
105-
10696
fromMatches = currentMatches.filter(function (match) {
10797
return !hasMatch(nextMatches, match);
10898
});
@@ -219,6 +209,14 @@ function runHooks(hooks, callback) {
219209
}
220210
}
221211

212+
function updateMatchComponents(matches, refs) {
213+
var i = 0, component;
214+
while (component = refs.__activeRoute__) {
215+
matches[i++].component = component;
216+
refs = component.refs;
217+
}
218+
}
219+
222220
function returnNull() {
223221
return null;
224222
}
@@ -329,6 +327,8 @@ var Routes = React.createClass({
329327
} else if (abortReason) {
330328
this.goBack();
331329
} else {
330+
updateMatchComponents(this.state.matches, this.refs);
331+
332332
this.updateScroll(path, actionType);
333333

334334
if (this.props.onChange)

0 commit comments

Comments
 (0)