File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/** @jsx React.DOM */
22var React = require ( 'react' ) ;
33var Modal = require ( '../../lib/index' ) ;
4- require ( 'react-tap-event-plugin' ) ( ) ;
54
65var appElement = document . getElementById ( 'example' ) ;
76
@@ -10,22 +9,32 @@ Modal.injectCSS();
109
1110var App = React . createClass ( {
1211
12+ getInitialState : function ( ) {
13+ return { modalIsOpen : false } ;
14+ } ,
15+
1316 openModal : function ( ) {
14- this . refs . modal . open ( ) ;
17+ this . setState ( { modalIsOpen : true } ) ;
1518 } ,
1619
1720 closeModal : function ( ) {
18- this . refs . modal . close ( ) ;
21+ this . setState ( { modalIsOpen : false } ) ;
22+ } ,
23+
24+ handleModalCloseRequest : function ( ) {
25+ // opportunity to validate something and keep the modal open even if it
26+ // requested to be closed
27+ this . setState ( { modalIsOpen : false } ) ;
1928 } ,
2029
2130 render : function ( ) {
2231 return (
2332 < div >
2433 < button onClick = { this . openModal } > Open Modal</ button >
2534 < Modal
26- ref = "modal"
2735 closeTimeoutMS = { 150 }
28- dismissable = { true }
36+ isOpen = { this . state . modalIsOpen }
37+ onRequestClose = { this . handleModalCloseRequest }
2938 >
3039 < h1 > Hello</ h1 >
3140 < button onClick = { this . closeModal } > close</ button >
You can’t perform that action at this time.
0 commit comments