From ffbb86b361e5cfec0c3c5dcc2f5ab829e7f54527 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Wed, 28 Dec 2016 20:41:40 -0800 Subject: [PATCH] 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. --- src/renderers/dom/fiber/ReactDOMFiber.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/renderers/dom/fiber/ReactDOMFiber.js b/src/renderers/dom/fiber/ReactDOMFiber.js index 20d851dcee..a4ed6d3e54 100644 --- a/src/renderers/dom/fiber/ReactDOMFiber.js +++ b/src/renderers/dom/fiber/ReactDOMFiber.js @@ -322,9 +322,15 @@ function renderSubtreeIntoContainer(parentComponent : ?ReactComponent { + 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; + }); }); } },