Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/core/ReactCompositeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,15 @@ var ReactCompositeComponentMixin = {
replaceState: function(completeState, callback) {
validateLifeCycleOnReplaceState(this);
this._pendingState = completeState;
ReactUpdates.enqueueUpdate(this, callback);
if (this._compositeLifeCycleState !== CompositeLifeCycle.MOUNTING) {
// If we're in a componentWillMount handler, don't enqueue a rerender
// because ReactUpdates assumes we're in a browser context (which is wrong
// for server rendering) and we're about to do a render anyway.
// TODO: The callback here is ignored when setState is called from
// componentWillMount. Either fix it or disallow doing so completely in
// favor of getInitialState.
ReactUpdates.enqueueUpdate(this, callback);
}
},

/**
Expand Down
19 changes: 0 additions & 19 deletions src/core/ReactUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,6 @@ var flushBatchedUpdates = ReactPerf.measure(
// componentDidUpdate) but we need to check here too in order to catch
// updates enqueued by setState callbacks.
while (dirtyComponents.length) {
var allUnmounted = true;
for (var i = 0, l = dirtyComponents.length; i < l; i++) {
if (dirtyComponents[i].isMounted()) {
allUnmounted = false;
break;
}
}

if (allUnmounted) {
// All the "dirty" components are unmounted, which probably means that
// they were marked dirty due to setState calls in componentWillMount
// handlers and the components are currently in the process of mounting.
// `runBatchedUpdates` will be a noop. In that case, initializing the
// DOM-dependent ReactReconcileTransaction is thus not what we want to
// do, especially when using server rendering, so we skip it.
dirtyComponents.length = 0;
return;
}

var transaction = ReactUpdatesFlushTransaction.getPooled();
transaction.perform(runBatchedUpdates, null, transaction);
ReactUpdatesFlushTransaction.release(transaction);
Expand Down