Skip to content

Commit 03ae0a9

Browse files
committed
Drop ReactOwner.Mixin
This is not used anywhere else. To avoid overabstraction we should just inline this.
1 parent 519ee32 commit 03ae0a9

File tree

2 files changed

+29
-45
lines changed

2 files changed

+29
-45
lines changed

src/core/ReactCompositeComponent.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ var ReactContext = require('ReactContext');
1616
var ReactCurrentOwner = require('ReactCurrentOwner');
1717
var ReactElement = require('ReactElement');
1818
var ReactInstanceMap = require('ReactInstanceMap');
19-
var ReactOwner = require('ReactOwner');
2019
var ReactPerf = require('ReactPerf');
2120
var ReactPropTypeLocations = require('ReactPropTypeLocations');
2221
var ReactUpdates = require('ReactUpdates');
2322

2423
var assign = require('Object.assign');
24+
var emptyObject = require('emptyObject');
2525
var invariant = require('invariant');
2626
var keyMirror = require('keyMirror');
2727
var shouldUpdateReactComponent = require('shouldUpdateReactComponent');
@@ -100,8 +100,7 @@ var CompositeLifeCycle = keyMirror({
100100
* @lends {ReactCompositeComponent.prototype}
101101
*/
102102
var ReactCompositeComponentMixin = assign({},
103-
ReactComponent.Mixin,
104-
ReactOwner.Mixin, {
103+
ReactComponent.Mixin, {
105104

106105
/**
107106
* Base constructor for all composite component.
@@ -114,13 +113,13 @@ var ReactCompositeComponentMixin = assign({},
114113
this._instance.props = element.props;
115114
this._instance.state = null;
116115
this._instance.context = null;
116+
this._instance.refs = emptyObject;
117117

118118
this._pendingState = null;
119119
this._compositeLifeCycleState = null;
120120

121121
// Children can be either an array or more than one argument
122122
ReactComponent.Mixin.construct.apply(this, arguments);
123-
ReactOwner.Mixin.construct.apply(this, arguments);
124123
},
125124

126125
/**
@@ -699,6 +698,32 @@ var ReactCompositeComponentMixin = assign({},
699698
}
700699
),
701700

701+
/**
702+
* Lazily allocates the refs object and stores `component` as `ref`.
703+
*
704+
* @param {string} ref Reference name.
705+
* @param {component} component Component to store as `ref`.
706+
* @final
707+
* @private
708+
*/
709+
attachRef: function(ref, component) {
710+
var inst = this.getPublicInstance();
711+
var refs = inst.refs === emptyObject ? (inst.refs = {}) : inst.refs;
712+
refs[ref] = component.getPublicInstance();
713+
},
714+
715+
/**
716+
* Detaches a reference name.
717+
*
718+
* @param {string} ref Name to dereference.
719+
* @final
720+
* @private
721+
*/
722+
detachRef: function(ref) {
723+
var refs = this.getPublicInstance().refs;
724+
delete refs[ref];
725+
},
726+
702727
/**
703728
* Get the publicly accessible representation of this component - i.e. what
704729
* is exposed by refs and renderComponent. Can be null for stateless

src/core/ReactOwner.js

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
"use strict";
1313

14-
var emptyObject = require('emptyObject');
1514
var invariant = require('invariant');
1615

1716
/**
@@ -103,46 +102,6 @@ var ReactOwner = {
103102
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
104103
owner.detachRef(ref);
105104
}
106-
},
107-
108-
/**
109-
* A ReactComponent must mix this in to have refs.
110-
*
111-
* @lends {ReactOwner.prototype}
112-
*/
113-
Mixin: {
114-
115-
construct: function() {
116-
var inst = this.getPublicInstance();
117-
inst.refs = emptyObject;
118-
},
119-
120-
/**
121-
* Lazily allocates the refs object and stores `component` as `ref`.
122-
*
123-
* @param {string} ref Reference name.
124-
* @param {component} component Component to store as `ref`.
125-
* @final
126-
* @private
127-
*/
128-
attachRef: function(ref, component) {
129-
var inst = this.getPublicInstance();
130-
var refs = inst.refs === emptyObject ? (inst.refs = {}) : inst.refs;
131-
refs[ref] = component.getPublicInstance();
132-
},
133-
134-
/**
135-
* Detaches a reference name.
136-
*
137-
* @param {string} ref Name to dereference.
138-
* @final
139-
* @private
140-
*/
141-
detachRef: function(ref) {
142-
var refs = this.getPublicInstance().refs;
143-
delete refs[ref];
144-
}
145-
146105
}
147106

148107
};

0 commit comments

Comments
 (0)