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.
This commit is contained in:
Sebastian Markbage
2015-06-18 12:36:50 -07:00
parent 7443f63ae9
commit 3af73834d9
4 changed files with 3 additions and 24 deletions
@@ -265,19 +265,15 @@ var ReactCompositeComponentMixin = {
var inst = this._instance;
if (inst.componentWillUnmount) {
var previouslyUnmounting = ReactLifeCycle.currentlyUnmountingInstance;
ReactLifeCycle.currentlyUnmountingInstance = this;
try {
inst.componentWillUnmount();
} finally {
ReactLifeCycle.currentlyUnmountingInstance = previouslyUnmounting;
}
inst.componentWillUnmount();
}
ReactReconciler.unmountComponent(this._renderedComponent);
this._renderedComponent = null;
// Reset pending fields
// Even if this component is scheduled for another update in ReactUpdates,
// it would still be ignored because these fields are reset.
this._pendingStateQueue = null;
this._pendingReplaceState = false;
this._pendingForceUpdate = false;
@@ -20,16 +20,10 @@
* currentlyMountingInstance: During the construction phase, it is not possible
* to trigger an update since the instance is not fully mounted yet. However, we
* currently allow this as a convenience for mutating the initial state.
*
* currentlyUnmountingInstance: During the unmounting phase, the instance is
* still mounted and can therefore schedule an update. However, this is not
* recommended and probably an error since it's about to be unmounted.
* Therefore we still want to trigger in an error for that case.
*/
var ReactLifeCycle = {
currentlyMountingInstance: null,
currentlyUnmountingInstance: null,
};
module.exports = ReactLifeCycle;
@@ -61,10 +61,6 @@ function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
return null;
}
if (internalInstance === ReactLifeCycle.currentlyUnmountingInstance) {
return null;
}
return internalInstance;
}
@@ -89,10 +89,6 @@ var CompositeComponentLifeCycle = keyMirror({
* receiving new props.
*/
MOUNTING: null,
/**
* Unmounted components are inactive and cannot receive new props.
*/
UNMOUNTING: null,
});
function getCompositeLifeCycle(instance) {
@@ -103,9 +99,6 @@ function getCompositeLifeCycle(instance) {
if (ReactLifeCycle.currentlyMountingInstance === internalInstance) {
return CompositeComponentLifeCycle.MOUNTING;
}
if (ReactLifeCycle.currentlyUnmountingInstance === internalInstance) {
return CompositeComponentLifeCycle.UNMOUNTING;
}
return null;
}