File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,14 +2,15 @@ import React, {Component} from 'react';
22
33export class TransitionBase extends Component {
44 defer = [ ] ;
5+ mounted = false ;
56
67 deferParent ( func ) {
78 this . defer . push ( func ) ;
89 }
910
1011 wrapChild ( child ) {
1112 return React . cloneElement ( child , {
12- parent : this . native ,
13+ parent : this ,
1314 onParentMount : this . deferParent . bind ( this )
1415 } ) ;
1516 }
@@ -23,9 +24,20 @@ export class TransitionBase extends Component {
2324 }
2425
2526 mount ( ) {
26- if ( this . props . onParentMount && this . props . parent )
27- this . props . onParentMount ( ( ) => this . props . parent . add ( this . native ) ) ;
27+ if ( this . props . parent )
28+ if ( this . props . parent . mounted )
29+ this . props . parent . native . add ( this . native ) ;
30+ else if ( this . props . onParentMount )
31+ this . props . onParentMount ( ( ) => this . props . parent . native . add ( this . native ) ) ;
2832
2933 this . defer . forEach ( func => func ( ) ) ;
34+ this . mounted = true ;
35+ }
36+
37+ unmount ( ) {
38+ if ( this . props . parent )
39+ this . props . parent . native . remove ( this . native ) ;
40+
41+ this . mounted = false ;
3042 }
3143}
Original file line number Diff line number Diff line change @@ -18,5 +18,9 @@ export function reactify(component) {
1818 componentDidMount ( ) {
1919 this . mount ( ) ;
2020 }
21+
22+ componentWillUnmount ( ) {
23+ this . unmount ( ) ;
24+ }
2125 }
2226}
You can’t perform that action at this time.
0 commit comments