@samitouri / QOS-React-2 / commits / 3af73834d9

Remove currentlyUnmountingComponent

This was used for any invariant that was subsequently removed. It turns out that this is completely unnecessary now. Any setState calls will enqueue and update and the component added to the update queue. However, since the pending fields are reset after componentWillUnmount, any update will still be ignored.

Sebastian Markbage committed Jun 18, 2015 at 09:19 UTC 3af73834d932bb5b6c13e7e5eb60bc2c0718c2da
4 files changed +3 -24
src/renderers/shared/reconciler/ReactCompositeComponent.js
+3 -7
@@ -265,19 +265,15 @@ var ReactCompositeComponentMixin = {
265 var inst = this._instance;
266
267 if (inst.componentWillUnmount) {
268 - var previouslyUnmounting = ReactLifeCycle.currentlyUnmountingInstance;
269 - ReactLifeCycle.currentlyUnmountingInstance = this;
270 - try {
271 - inst.componentWillUnmount();
272 - } finally {
273 - ReactLifeCycle.currentlyUnmountingInstance = previouslyUnmounting;
274 - }
268 + inst.componentWillUnmount();
269 }
270
271 ReactReconciler.unmountComponent(this._renderedComponent);
272 this._renderedComponent = null;
273
274 // Reset pending fields
275 + // Even if this component is scheduled for another update in ReactUpdates,
276 + // it would still be ignored because these fields are reset.
277 this._pendingStateQueue = null;
278 this._pendingReplaceState = false;
279 this._pendingForceUpdate = false;
src/renderers/shared/reconciler/ReactLifeCycle.js
-6
@@ -20,16 +20,10 @@
20 * currentlyMountingInstance: During the construction phase, it is not possible
21 * to trigger an update since the instance is not fully mounted yet. However, we
22 * currently allow this as a convenience for mutating the initial state.
23 - *
24 - * currentlyUnmountingInstance: During the unmounting phase, the instance is
25 - * still mounted and can therefore schedule an update. However, this is not
26 - * recommended and probably an error since it's about to be unmounted.
27 - * Therefore we still want to trigger in an error for that case.
23 */
24
25 var ReactLifeCycle = {
26 currentlyMountingInstance: null,
32 - currentlyUnmountingInstance: null,
27 };
28
29 module.exports = ReactLifeCycle;
src/renderers/shared/reconciler/ReactUpdateQueue.js
-4
@@ -61,10 +61,6 @@ function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
61 return null;
62 }
63
64 - if (internalInstance === ReactLifeCycle.currentlyUnmountingInstance) {
65 - return null;
66 - }
67 -
64 return internalInstance;
65 }
66
src/renderers/shared/reconciler/__tests__/ReactComponentLifeCycle-test.js
-7
@@ -89,10 +89,6 @@ var CompositeComponentLifeCycle = keyMirror({
89 * receiving new props.
90 */
91 MOUNTING: null,
92 - /**
93 - * Unmounted components are inactive and cannot receive new props.
94 - */
95 - UNMOUNTING: null,
92 });
93
94 function getCompositeLifeCycle(instance) {
@@ -103,9 +99,6 @@ function getCompositeLifeCycle(instance) {
99 if (ReactLifeCycle.currentlyMountingInstance === internalInstance) {
100 return CompositeComponentLifeCycle.MOUNTING;
101 }
106 - if (ReactLifeCycle.currentlyUnmountingInstance === internalInstance) {
107 - return CompositeComponentLifeCycle.UNMOUNTING;
108 - }
102 return null;
103 }
104