Skip to content

Commit 13fe784

Browse files
committed
Do not prefetch async state if handler of the same type
This matches the behaviour of getInitialAsyncState (w/o prefetchAsyncState call) and of getInitialState. If an async state depends on props, then one would need to initiate its update directly from componentWillReceiveProps (like one would do with regular state).
1 parent 154b06e commit 13fe784

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/AsyncRouteRenderingMixin.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ var AsyncRouteRenderingMixin = {
1313
mixins: [RouteRenderingMixin],
1414

1515
setRoutingState: function(state, cb) {
16-
if (state.handler && isAsyncComponent(state.handler)) {
16+
var currentHandler = this.state && this.state.handler;
17+
var nextHandler = state && state.handler;
18+
19+
if (nextHandler &&
20+
isAsyncComponent(nextHandler) &&
21+
// if component's type is the same we would need to skip async state
22+
// update
23+
!(currentHandler && currentHandler.type === nextHandler.type)) {
1724
// store pending state and start fetching async state of a new handler
1825
this.setState(
1926
{pendingState: state},

0 commit comments

Comments
 (0)