Skip to content
Closed
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
8 changes: 6 additions & 2 deletions src/browser/ui/ReactDOMIDOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@ var ReactDOMIDOperations = {
dangerouslyReplaceNodeWithMarkupByID: ReactPerf.measure(
'ReactDOMIDOperations',
'dangerouslyReplaceNodeWithMarkupByID',
function(id, markup) {
function(id, markupCallback) {
var node = ReactMount.getNode(id);
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
var markup = markupCallback();
DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(
node,
markup
);
}
),

Expand Down
25 changes: 17 additions & 8 deletions src/core/ReactCompositeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1167,16 +1167,25 @@ var ReactCompositeComponentMixin = {
// These two IDs are actually the same! But nothing should rely on that.
var thisID = this._rootNodeID;
var prevComponentID = prevComponentInstance._rootNodeID;
prevComponentInstance.unmountComponent();
this._renderedComponent = instantiateReactComponent(nextDescriptor);
var nextMarkup = this._renderedComponent.mountComponent(
thisID,
transaction,
this._mountDepth + 1
);

// This callback pattern is a temporary workaround until a refactor is
// carried out. The problem it solves is that even though prevComponent
// was unmounted (and its ID purged), its ID would later be used for
// dangerouslyReplaceNodeWithMarkupByID.
var thisComponent = this;
ReactComponent.BackendIDOperations.dangerouslyReplaceNodeWithMarkupByID(
prevComponentID,
nextMarkup
function() {
prevComponentInstance.unmountComponent();
thisComponent._renderedComponent =
instantiateReactComponent(nextDescriptor);
var nextMarkup = thisComponent._renderedComponent.mountComponent(
thisID,
transaction,
thisComponent._mountDepth + 1
);
return nextMarkup;
}
);
}
}
Expand Down