@@ -4,6 +4,7 @@ import deprecationWarning from './utils/deprecationWarning';
44
55import createChainedFunction from './utils/createChainedFunction' ;
66import createContextWrapper from './utils/createContextWrapper' ;
7+ import { OverlayMixin } from './OverlayMixin' ;
78
89function createHideDepreciationWrapper ( hide ) {
910 return function ( ...args ) {
@@ -16,6 +17,8 @@ function createHideDepreciationWrapper(hide){
1617
1718const ModalTrigger = React . createClass ( {
1819
20+ mixins : [ OverlayMixin ] ,
21+
1922 propTypes : {
2023 modal : React . PropTypes . node . isRequired ,
2124 /**
@@ -28,6 +31,7 @@ const ModalTrigger = React.createClass({
2831 onMouseOver : React . PropTypes . func
2932 } ,
3033
34+
3135 getInitialState ( ) {
3236 return {
3337 isOverlayShown : false
@@ -52,31 +56,19 @@ const ModalTrigger = React.createClass({
5256 } ) ;
5357 } ,
5458
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 ( ) {
7160 let modal = this . props . modal ;
7261
62+ if ( ! this . state . isOverlayShown ) {
63+ return < span /> ;
64+ }
65+
7366 return cloneElement (
7467 modal ,
7568 {
76- show : this . state . isOverlayShown ,
7769 onHide : this . hide ,
7870 onRequestHide : createHideDepreciationWrapper ( this . hide ) ,
79- container : modal . props . container || this . props . container
71+ __isUsedInModalTrigger : true
8072 }
8173 ) ;
8274 } ,
0 commit comments