Drop this.props
Sebastian Markbage committed
Nov 16, 2014 at 01:44 UTC
519ee322ca53f03a4b9ed6150295340b59588dd6
3 files changed
+11
-14
src/browser/ui/ReactDOMComponent.js
+9
-7
@@ -173,8 +173,8 @@ ReactDOMComponent.Mixin = {
173
transaction,
174
mountDepth
175
);
176
- assertValidProps(this.props);
176
this._previousStyleCopy = null;
177
+ assertValidProps(this._currentElement.props);
178
var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
179
return (
180
this._createOpenTagMarkupAndPutListeners(transaction) +
@@ -197,7 +197,7 @@ ReactDOMComponent.Mixin = {
197
* @return {string} Markup of opening tag.
198
*/
199
_createOpenTagMarkupAndPutListeners: function(transaction) {
200
- var props = this.props;
200
+ var props = this._currentElement.props;
201
var ret = '<' + this._tag;
202
203
for (var propKey in props) {
@@ -253,16 +253,18 @@ ReactDOMComponent.Mixin = {
253
prefix = '\n';
254
}
255
256
+ var props = this._currentElement.props;
257
+
258
// Intentional use of != to avoid catching zero/false.
257
- var innerHTML = this.props.dangerouslySetInnerHTML;
259
+ var innerHTML = props.dangerouslySetInnerHTML;
260
if (innerHTML != null) {
261
if (innerHTML.__html != null) {
262
return prefix + innerHTML.__html;
263
}
264
} else {
265
var contentToUse =
264
- CONTENT_TYPES[typeof this.props.children] ? this.props.children : null;
265
- var childrenToUse = contentToUse != null ? null : this.props.children;
266
+ CONTENT_TYPES[typeof props.children] ? props.children : null;
267
+ var childrenToUse = contentToUse != null ? null : props.children;
268
if (contentToUse != null) {
269
return prefix + escapeTextForBrowser(contentToUse);
270
} else if (childrenToUse != null) {
@@ -338,7 +340,7 @@ ReactDOMComponent.Mixin = {
340
* @param {ReactReconcileTransaction} transaction
341
*/
342
_updateDOMProperties: function(lastProps, transaction) {
341
- var nextProps = this.props;
343
+ var nextProps = this._currentElement.props;
344
var propKey;
345
var styleName;
346
var styleUpdates;
@@ -427,7 +429,7 @@ ReactDOMComponent.Mixin = {
429
* @param {ReactReconcileTransaction} transaction
430
*/
431
_updateDOMChildren: function(lastProps, transaction) {
430
- var nextProps = this.props;
432
+ var nextProps = this._currentElement.props;
433
434
var lastContent =
435
CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
src/browser/ui/__tests__/ReactDOMComponent-test.js
+2
-2
@@ -226,7 +226,7 @@ describe('ReactDOMComponent', function() {
226
var ReactReconcileTransaction = require('ReactReconcileTransaction');
227
228
var NodeStub = function(initialProps) {
229
- this.props = initialProps || {};
229
+ this._currentElement = { props: initialProps };
230
this._rootNodeID = 'test';
231
};
232
assign(NodeStub.prototype, ReactDOMComponent.Mixin);
@@ -276,7 +276,7 @@ describe('ReactDOMComponent', function() {
276
var ReactReconcileTransaction = require('ReactReconcileTransaction');
277
278
var NodeStub = function(initialProps) {
279
- this.props = initialProps || {};
279
+ this._currentElement = { props: initialProps };
280
this._rootNodeID = 'test';
281
};
282
assign(NodeStub.prototype, ReactDOMComponent.Mixin);
src/core/ReactComponent.js
-5
@@ -225,10 +225,6 @@ var ReactComponent = {
225
* @internal
226
*/
227
construct: function(element) {
228
- // This is the public exposed props object after it has been processed
229
- // with default props. The element's props represents the true internal
230
- // state of the props.
231
- this.props = element.props;
228
// Record the component responsible for creating this component.
229
// This is accessible through the element but we maintain an extra
230
// field for compatibility with devtools and as a way to make an
@@ -337,7 +333,6 @@ var ReactComponent = {
333
var prevElement = this._currentElement;
334
var nextElement = this._pendingElement;
335
this._currentElement = nextElement;
340
- this.props = nextElement.props;
336
this._owner = nextElement._owner;
337
this._pendingElement = null;
338
this.updateComponent(transaction, prevElement, nextElement);