@@ -4,6 +4,7 @@ import deprecationWarning from './utils/deprecationWarning';
4
4
5
5
import createChainedFunction from './utils/createChainedFunction' ;
6
6
import createContextWrapper from './utils/createContextWrapper' ;
7
+ import { OverlayMixin } from './OverlayMixin' ;
7
8
8
9
function createHideDepreciationWrapper ( hide ) {
9
10
return function ( ...args ) {
@@ -16,6 +17,8 @@ function createHideDepreciationWrapper(hide){
16
17
17
18
const ModalTrigger = React . createClass ( {
18
19
20
+ mixins : [ OverlayMixin ] ,
21
+
19
22
propTypes : {
20
23
modal : React . PropTypes . node . isRequired ,
21
24
/**
@@ -28,6 +31,7 @@ const ModalTrigger = React.createClass({
28
31
onMouseOver : React . PropTypes . func
29
32
} ,
30
33
34
+
31
35
getInitialState ( ) {
32
36
return {
33
37
isOverlayShown : false
@@ -52,31 +56,19 @@ const ModalTrigger = React.createClass({
52
56
} ) ;
53
57
} ,
54
58
55
- componentDidMount ( ) {
56
- this . _overlay = document . createElement ( 'div' ) ;
57
- React . render ( this . getOverlay ( ) , this . _overlay ) ;
58
- } ,
59
-
60
- componentWillUnmount ( ) {
61
- React . unmountComponentAtNode ( this . _overlay ) ;
62
- this . _overlay = null ;
63
- clearTimeout ( this . _hoverDelay ) ;
64
- } ,
65
-
66
- componentDidUpdate ( ) {
67
- React . render ( this . getOverlay ( ) , this . _overlay ) ;
68
- } ,
69
-
70
- getOverlay ( ) {
59
+ renderOverlay ( ) {
71
60
let modal = this . props . modal ;
72
61
62
+ if ( ! this . state . isOverlayShown ) {
63
+ return < span /> ;
64
+ }
65
+
73
66
return cloneElement (
74
67
modal ,
75
68
{
76
- show : this . state . isOverlayShown ,
77
69
onHide : this . hide ,
78
70
onRequestHide : createHideDepreciationWrapper ( this . hide ) ,
79
- container : modal . props . container || this . props . container
71
+ __isUsedInModalTrigger : true
80
72
}
81
73
) ;
82
74
} ,
0 commit comments