mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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;
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user