mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Move _pendingX into ReactCompositeComponent
Since setProps can no longer be called on anything but composites, we can move this complexity into ReactCompositeComponent.
This commit is contained in:
@@ -291,11 +291,9 @@ ReactDOMComponent.Mixin = {
|
||||
return;
|
||||
}
|
||||
|
||||
ReactComponent.Mixin.receiveComponent.call(
|
||||
this,
|
||||
nextElement,
|
||||
transaction
|
||||
);
|
||||
var prevElement = this._currentElement;
|
||||
this._currentElement = nextElement;
|
||||
this.updateComponent(transaction, prevElement, nextElement);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,13 +115,9 @@ var ReactComponent = {
|
||||
* @internal
|
||||
*/
|
||||
construct: function(element) {
|
||||
// See ReactUpdates.
|
||||
this._pendingCallbacks = null;
|
||||
|
||||
// We keep the old element and a reference to the pending element
|
||||
// to track updates.
|
||||
this._currentElement = element;
|
||||
this._pendingElement = null;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -167,41 +163,6 @@ var ReactComponent = {
|
||||
unmountIDFromEnvironment(this._rootNodeID);
|
||||
// Reset all fields
|
||||
this._rootNodeID = null;
|
||||
this._pendingCallbacks = null;
|
||||
this._pendingElement = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a new instance of this component, updates the rendered DOM nodes
|
||||
* as if that instance was rendered instead.
|
||||
*
|
||||
* Subclasses that override this method should make sure to invoke
|
||||
* `ReactComponent.Mixin.receiveComponent.call(this, ...)`.
|
||||
*
|
||||
* @param {object} nextComponent Next set of properties.
|
||||
* @param {ReactReconcileTransaction} transaction
|
||||
* @internal
|
||||
*/
|
||||
receiveComponent: function(nextElement, transaction) {
|
||||
this._pendingElement = nextElement;
|
||||
this.performUpdateIfNecessary(transaction);
|
||||
},
|
||||
|
||||
/**
|
||||
* If `_pendingElement` is set, update the component.
|
||||
*
|
||||
* @param {ReactReconcileTransaction} transaction
|
||||
* @internal
|
||||
*/
|
||||
performUpdateIfNecessary: function(transaction) {
|
||||
if (this._pendingElement == null) {
|
||||
return;
|
||||
}
|
||||
var prevElement = this._currentElement;
|
||||
var nextElement = this._pendingElement;
|
||||
this._currentElement = nextElement;
|
||||
this._pendingElement = null;
|
||||
this.updateComponent(transaction, prevElement, nextElement);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,11 +115,15 @@ var ReactCompositeComponentMixin = assign({},
|
||||
this._instance.context = null;
|
||||
this._instance.refs = emptyObject;
|
||||
|
||||
this._pendingElement = null;
|
||||
this._pendingState = null;
|
||||
this._compositeLifeCycleState = null;
|
||||
|
||||
// Children can be either an array or more than one argument
|
||||
ReactComponent.Mixin.construct.apply(this, arguments);
|
||||
|
||||
// See ReactUpdates.
|
||||
this._pendingCallbacks = null;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -234,6 +238,9 @@ var ReactCompositeComponentMixin = assign({},
|
||||
// Reset pending fields
|
||||
this._pendingState = null;
|
||||
this._pendingForceUpdate = false;
|
||||
this._pendingCallbacks = null;
|
||||
this._pendingElement = null;
|
||||
|
||||
ReactComponent.Mixin.unmountComponent.call(this);
|
||||
|
||||
// Delete the reference from the instance to this internal representation
|
||||
@@ -505,11 +512,8 @@ var ReactCompositeComponentMixin = assign({},
|
||||
return;
|
||||
}
|
||||
|
||||
ReactComponent.Mixin.receiveComponent.call(
|
||||
this,
|
||||
nextElement,
|
||||
transaction
|
||||
);
|
||||
this._pendingElement = nextElement;
|
||||
this.performUpdateIfNecessary(transaction);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user