@samitouri / QOS-React / commits / aea55609bf

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.

Sebastian Markbage committed Nov 16, 2016 at 12:50 UTC aea55609bfdd02736e00daa32322e9efd02b67b7
1 file changed +2 -37
src/renderers/dom/fiber/ReactDOMFiberComponent.js
+2 -37
@@ -515,6 +515,8 @@ var ReactDOMFiberComponent = {
515 case 'input':
516 ReactDOMFiberInput.mountWrapper(workInProgress, props, hostParent);
517 props = ReactDOMFiberInput.getHostProps(workInProgress, props);
518 + // TODO: Make sure we check if this is still unmounted or do any clean
519 + // up necessary since we never stop tracking anymore.
520 inputValueTracking.track(workInProgress);
521 trapBubbledEventsLocal(workInProgress);
522 // For controlled components we always need to ensure we're listening
@@ -711,43 +713,6 @@ var ReactDOMFiberComponent = {
713 }
714 },
715
714 - /**
715 - * Destroys all event registrations for workInProgress instance. Does not remove from
716 - * the DOM. That must be done by the parent.
717 - *
718 - * @internal
719 - */
720 - unmountComponent: function(safely, skipLifecycle) {
721 - switch (workInProgress._tag) {
722 - case 'input':
723 - case 'textarea':
724 - inputValueTracking.stopTracking(workInProgress);
725 - break;
726 - case 'html':
727 - case 'head':
728 - case 'body':
729 - /**
730 - * Components like <html> <head> and <body> can't be removed or added
731 - * easily in a cross-browser way, however it's valuable to be able to
732 - * take advantage of React's reconciliation for styling and <title>
733 - * management. So we just document it and throw in dangerous cases.
734 - */
735 - invariant(
736 - false,
737 - '<%s> tried to unmount. Because of cross-browser quirks it is ' +
738 - 'impossible to unmount some top-level components (eg <html>, ' +
739 - '<head>, and <body>) reliably and efficiently. To fix workInProgress, have a ' +
740 - 'single top-level component that never unmounts render these ' +
741 - 'elements.',
742 - workInProgress._tag
743 - );
744 - break;
745 - }
746 -
747 - ReactDOMComponentTree.uncacheNode(workInProgress);
748 - workInProgress._wrapperState = null;
749 - },
750 -
716 restoreControlledState: function(finishedWork : Fiber) {
717 switch (finishedWork.type) {
718 case 'input':