Skip to content

Commit bc4dd41

Browse files
committed
Move _pendingX into ReactCompositeComponent
Since setProps can no longer be called on anything but composites, we can move this complexity into ReactCompositeComponent.
1 parent 974a4c8 commit bc4dd41

File tree

3 files changed

+12
-49
lines changed

3 files changed

+12
-49
lines changed

src/browser/ui/ReactDOMComponent.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,9 @@ ReactDOMComponent.Mixin = {
291291
return;
292292
}
293293

294-
ReactComponent.Mixin.receiveComponent.call(
295-
this,
296-
nextElement,
297-
transaction
298-
);
294+
var prevElement = this._currentElement;
295+
this._currentElement = nextElement;
296+
this.updateComponent(transaction, prevElement, nextElement);
299297
},
300298

301299
/**

src/core/ReactComponent.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,9 @@ var ReactComponent = {
115115
* @internal
116116
*/
117117
construct: function(element) {
118-
// See ReactUpdates.
119-
this._pendingCallbacks = null;
120-
121118
// We keep the old element and a reference to the pending element
122119
// to track updates.
123120
this._currentElement = element;
124-
this._pendingElement = null;
125121
},
126122

127123
/**
@@ -167,41 +163,6 @@ var ReactComponent = {
167163
unmountIDFromEnvironment(this._rootNodeID);
168164
// Reset all fields
169165
this._rootNodeID = null;
170-
this._pendingCallbacks = null;
171-
this._pendingElement = null;
172-
},
173-
174-
/**
175-
* Given a new instance of this component, updates the rendered DOM nodes
176-
* as if that instance was rendered instead.
177-
*
178-
* Subclasses that override this method should make sure to invoke
179-
* `ReactComponent.Mixin.receiveComponent.call(this, ...)`.
180-
*
181-
* @param {object} nextComponent Next set of properties.
182-
* @param {ReactReconcileTransaction} transaction
183-
* @internal
184-
*/
185-
receiveComponent: function(nextElement, transaction) {
186-
this._pendingElement = nextElement;
187-
this.performUpdateIfNecessary(transaction);
188-
},
189-
190-
/**
191-
* If `_pendingElement` is set, update the component.
192-
*
193-
* @param {ReactReconcileTransaction} transaction
194-
* @internal
195-
*/
196-
performUpdateIfNecessary: function(transaction) {
197-
if (this._pendingElement == null) {
198-
return;
199-
}
200-
var prevElement = this._currentElement;
201-
var nextElement = this._pendingElement;
202-
this._currentElement = nextElement;
203-
this._pendingElement = null;
204-
this.updateComponent(transaction, prevElement, nextElement);
205166
},
206167

207168
/**

src/core/ReactCompositeComponent.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,15 @@ var ReactCompositeComponentMixin = assign({},
115115
this._instance.context = null;
116116
this._instance.refs = emptyObject;
117117

118+
this._pendingElement = null;
118119
this._pendingState = null;
119120
this._compositeLifeCycleState = null;
120121

121122
// Children can be either an array or more than one argument
122123
ReactComponent.Mixin.construct.apply(this, arguments);
124+
125+
// See ReactUpdates.
126+
this._pendingCallbacks = null;
123127
},
124128

125129
/**
@@ -234,6 +238,9 @@ var ReactCompositeComponentMixin = assign({},
234238
// Reset pending fields
235239
this._pendingState = null;
236240
this._pendingForceUpdate = false;
241+
this._pendingCallbacks = null;
242+
this._pendingElement = null;
243+
237244
ReactComponent.Mixin.unmountComponent.call(this);
238245

239246
// Delete the reference from the instance to this internal representation
@@ -505,11 +512,8 @@ var ReactCompositeComponentMixin = assign({},
505512
return;
506513
}
507514

508-
ReactComponent.Mixin.receiveComponent.call(
509-
this,
510-
nextElement,
511-
transaction
512-
);
515+
this._pendingElement = nextElement;
516+
this.performUpdateIfNecessary(transaction);
513517
},
514518

515519
/**

0 commit comments

Comments
 (0)