Drop ReactOwner.Mixin
This is not used anywhere else. To avoid overabstraction we should just inline this.
Sebastian Markbage committed
Nov 16, 2014 at 01:54 UTC
03ae0a906b8cf168361113a2afe56f482fe4de66
2 files changed
+29
-45
src/core/ReactCompositeComponent.js
+29
-4
@@ -16,12 +16,12 @@ var ReactContext = require('ReactContext');
16
var ReactCurrentOwner = require('ReactCurrentOwner');
17
var ReactElement = require('ReactElement');
18
var ReactInstanceMap = require('ReactInstanceMap');
19
-var ReactOwner = require('ReactOwner');
19
var ReactPerf = require('ReactPerf');
20
var ReactPropTypeLocations = require('ReactPropTypeLocations');
21
var ReactUpdates = require('ReactUpdates');
22
23
var assign = require('Object.assign');
24
+var emptyObject = require('emptyObject');
25
var invariant = require('invariant');
26
var keyMirror = require('keyMirror');
27
var shouldUpdateReactComponent = require('shouldUpdateReactComponent');
@@ -100,8 +100,7 @@ var CompositeLifeCycle = keyMirror({
100
* @lends {ReactCompositeComponent.prototype}
101
*/
102
var ReactCompositeComponentMixin = assign({},
103
- ReactComponent.Mixin,
104
- ReactOwner.Mixin, {
103
+ ReactComponent.Mixin, {
104
105
/**
106
* Base constructor for all composite component.
@@ -114,13 +113,13 @@ var ReactCompositeComponentMixin = assign({},
113
this._instance.props = element.props;
114
this._instance.state = null;
115
this._instance.context = null;
116
+ this._instance.refs = emptyObject;
117
118
this._pendingState = null;
119
this._compositeLifeCycleState = null;
120
121
// Children can be either an array or more than one argument
122
ReactComponent.Mixin.construct.apply(this, arguments);
123
- ReactOwner.Mixin.construct.apply(this, arguments);
123
},
124
125
/**
@@ -699,6 +698,32 @@ var ReactCompositeComponentMixin = assign({},
698
}
699
),
700
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
+
727
/**
728
* Get the publicly accessible representation of this component - i.e. what
729
* is exposed by refs and renderComponent. Can be null for stateless
src/core/ReactOwner.js
-41
@@ -11,7 +11,6 @@
11
12
"use strict";
13
14
-var emptyObject = require('emptyObject');
14
var invariant = require('invariant');
15
16
/**
@@ -103,46 +102,6 @@ var ReactOwner = {
102
if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
103
owner.detachRef(ref);
104
}
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
-
105
}
106
107
};