Wrap top-level mount and unmount in syncUpdates

For legacy purposes. Only enabled in the DOM renderer. We can remove
this in a future release when we enable incremental-by-default.

This change is unobservable because syncUpdates actually schedules
Task updates when it is called from inside another batch. The correct
behavior is to recursively begin another batch of work. We will fix it
in a subsequent commit.
This commit is contained in:
Andrew Clark
2016-12-28 20:41:40 -08:00
parent df6ca0e2c1
commit ffbb86b361
+13 -4
View File
@@ -322,9 +322,15 @@ function renderSubtreeIntoContainer(parentComponent : ?ReactComponent<any, any,
while (container.lastChild) {
container.removeChild(container.lastChild);
}
root = container._reactRootContainer = DOMRenderer.createContainer(container);
const newRoot = DOMRenderer.createContainer(container);
root = container._reactRootContainer = newRoot;
// Initial mount is always sync, even if we're in a batch.
DOMRenderer.syncUpdates(() => {
DOMRenderer.updateContainer(children, newRoot, parentComponent, callback);
});
} else {
DOMRenderer.updateContainer(children, root, parentComponent, callback);
}
DOMRenderer.updateContainer(children, root, parentComponent, callback);
return DOMRenderer.getPublicRootInstance(root);
}
@@ -346,8 +352,11 @@ var ReactDOM = {
unmountComponentAtNode(container : DOMContainerElement) {
warnAboutUnstableUse();
if (container._reactRootContainer) {
return renderSubtreeIntoContainer(null, null, container, () => {
container._reactRootContainer = null;
// Unmount is always sync, even if we're in a batch.
return DOMRenderer.syncUpdates(() => {
return renderSubtreeIntoContainer(null, null, container, () => {
container._reactRootContainer = null;
});
});
}
},