mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user