From aea55609bfdd02736e00daa32322e9efd02b67b7 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Wed, 16 Nov 2016 12:50:24 +0000 Subject: [PATCH] No need for unmounting DOM components We'll stop tracking the input value tracking. We'll also stop uncaching the node because we can just let the garbage collector take care of that. This makes it easier to release components in trees that never mounted. This also removes an invariant error which is covered by unit tests. This is necessary to separate regardless because we don't want this to fire for a component that was started but was thrown away because it never mounted. We can come back to that later. --- .../dom/fiber/ReactDOMFiberComponent.js | 39 +------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/src/renderers/dom/fiber/ReactDOMFiberComponent.js b/src/renderers/dom/fiber/ReactDOMFiberComponent.js index c78e180e75..9759562989 100644 --- a/src/renderers/dom/fiber/ReactDOMFiberComponent.js +++ b/src/renderers/dom/fiber/ReactDOMFiberComponent.js @@ -515,6 +515,8 @@ var ReactDOMFiberComponent = { case 'input': ReactDOMFiberInput.mountWrapper(workInProgress, props, hostParent); props = ReactDOMFiberInput.getHostProps(workInProgress, props); + // TODO: Make sure we check if this is still unmounted or do any clean + // up necessary since we never stop tracking anymore. inputValueTracking.track(workInProgress); trapBubbledEventsLocal(workInProgress); // For controlled components we always need to ensure we're listening @@ -711,43 +713,6 @@ var ReactDOMFiberComponent = { } }, - /** - * Destroys all event registrations for workInProgress instance. Does not remove from - * the DOM. That must be done by the parent. - * - * @internal - */ - unmountComponent: function(safely, skipLifecycle) { - switch (workInProgress._tag) { - case 'input': - case 'textarea': - inputValueTracking.stopTracking(workInProgress); - break; - case 'html': - case 'head': - case 'body': - /** - * Components like and can't be removed or added - * easily in a cross-browser way, however it's valuable to be able to - * take advantage of React's reconciliation for styling and - * management. So we just document it and throw in dangerous cases. - */ - invariant( - false, - '<%s> tried to unmount. Because of cross-browser quirks it is ' + - 'impossible to unmount some top-level components (eg <html>, ' + - '<head>, and <body>) reliably and efficiently. To fix workInProgress, have a ' + - 'single top-level component that never unmounts render these ' + - 'elements.', - workInProgress._tag - ); - break; - } - - ReactDOMComponentTree.uncacheNode(workInProgress); - workInProgress._wrapperState = null; - }, - restoreControlledState: function(finishedWork : Fiber) { switch (finishedWork.type) { case 'input':