diff --git a/src/browser/ui/ReactDOMComponent.js b/src/browser/ui/ReactDOMComponent.js index 3bdae4cb36..9ce81b1468 100644 --- a/src/browser/ui/ReactDOMComponent.js +++ b/src/browser/ui/ReactDOMComponent.js @@ -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); }, /** diff --git a/src/core/ReactComponent.js b/src/core/ReactComponent.js index fab20b257b..3803f891f5 100644 --- a/src/core/ReactComponent.js +++ b/src/core/ReactComponent.js @@ -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); }, /** diff --git a/src/core/ReactCompositeComponent.js b/src/core/ReactCompositeComponent.js index c02f91e080..bd076698be 100644 --- a/src/core/ReactCompositeComponent.js +++ b/src/core/ReactCompositeComponent.js @@ -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); }, /**