@@ -20,21 +20,6 @@ var assign = require('Object.assign');
2020var invariant = require ( 'invariant' ) ;
2121var keyMirror = require ( 'keyMirror' ) ;
2222
23- /**
24- * Every React component is in one of these life cycles.
25- */
26- var ComponentLifeCycle = keyMirror ( {
27- /**
28- * Mounted components have a DOM node representation and are capable of
29- * receiving new props.
30- */
31- MOUNTED : null ,
32- /**
33- * Unmounted components are inactive and cannot receive new props.
34- */
35- UNMOUNTED : null
36- } ) ;
37-
3823var injected = false ;
3924
4025/**
@@ -115,11 +100,6 @@ var ReactComponent = {
115100 }
116101 } ,
117102
118- /**
119- * @internal
120- */
121- LifeCycle : ComponentLifeCycle ,
122-
123103 /**
124104 * Injected module that provides ability to mutate individual properties.
125105 * Injected into the base class because many different subclasses need access
@@ -137,17 +117,6 @@ var ReactComponent = {
137117 */
138118 Mixin : {
139119
140- /**
141- * Checks whether or not this component is mounted.
142- *
143- * @return {boolean } True if mounted, false otherwise.
144- * @final
145- * @protected
146- */
147- isMounted : function ( ) {
148- return this . _lifeCycleState === ComponentLifeCycle . MOUNTED ;
149- } ,
150-
151120 /**
152121 * Sets a subset of the props.
153122 *
@@ -175,10 +144,6 @@ var ReactComponent = {
175144 * @public
176145 */
177146 replaceProps : function ( props , callback ) {
178- invariant (
179- this . isMounted ( ) ,
180- 'replaceProps(...): Can only update a mounted component.'
181- ) ;
182147 invariant (
183148 this . _mountDepth === 0 ,
184149 'replaceProps(...): You called `setProps` or `replaceProps` on a ' +
@@ -225,15 +190,6 @@ var ReactComponent = {
225190 * @internal
226191 */
227192 construct : function ( element ) {
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
231- // incremental update. TODO: Consider deprecating this field.
232- this . _owner = element . _owner ;
233-
234- // All components start unmounted.
235- this . _lifeCycleState = ComponentLifeCycle . UNMOUNTED ;
236-
237193 // See ReactUpdates.
238194 this . _pendingCallbacks = null ;
239195
@@ -258,20 +214,12 @@ var ReactComponent = {
258214 * @internal
259215 */
260216 mountComponent : function ( rootID , transaction , mountDepth ) {
261- invariant (
262- ! this . isMounted ( ) ,
263- 'mountComponent(%s, ...): Can only mount an unmounted component. ' +
264- 'Make sure to avoid storing components between renders or reusing a ' +
265- 'single component instance in multiple places.' ,
266- rootID
267- ) ;
268217 var ref = this . _currentElement . ref ;
269218 if ( ref != null ) {
270219 var owner = this . _currentElement . _owner ;
271220 attachRef ( ref , this , owner ) ;
272221 }
273222 this . _rootNodeID = rootID ;
274- this . _lifeCycleState = ComponentLifeCycle . MOUNTED ;
275223 this . _mountDepth = mountDepth ;
276224 // Effectively: return '';
277225 } ,
@@ -287,17 +235,15 @@ var ReactComponent = {
287235 * @internal
288236 */
289237 unmountComponent : function ( ) {
290- invariant (
291- this . isMounted ( ) ,
292- 'unmountComponent(): Can only unmount a mounted component.'
293- ) ;
294238 var ref = this . _currentElement . ref ;
295239 if ( ref != null ) {
296- detachRef ( ref , this , this . _owner ) ;
240+ detachRef ( ref , this , this . _currentElement . _owner ) ;
297241 }
298242 unmountIDFromEnvironment ( this . _rootNodeID ) ;
243+ // Reset all fields
299244 this . _rootNodeID = null ;
300- this . _lifeCycleState = ComponentLifeCycle . UNMOUNTED ;
245+ this . _pendingCallbacks = null ;
246+ this . _pendingElement = null ;
301247 } ,
302248
303249 /**
@@ -312,10 +258,6 @@ var ReactComponent = {
312258 * @internal
313259 */
314260 receiveComponent : function ( nextElement , transaction ) {
315- invariant (
316- this . isMounted ( ) ,
317- 'receiveComponent(...): Can only update a mounted component.'
318- ) ;
319261 this . _pendingElement = nextElement ;
320262 this . performUpdateIfNecessary ( transaction ) ;
321263 } ,
@@ -333,7 +275,6 @@ var ReactComponent = {
333275 var prevElement = this . _currentElement ;
334276 var nextElement = this . _pendingElement ;
335277 this . _currentElement = nextElement ;
336- this . _owner = nextElement . _owner ;
337278 this . _pendingElement = null ;
338279 this . updateComponent ( transaction , prevElement , nextElement ) ;
339280 } ,
0 commit comments