11import React , { Component } from 'react' ;
2- import Modal from '../../src/index ' ;
3- import ModalA from './modal_a ' ;
2+ import Modal from 'react-modal ' ;
3+ import MyModal from './modal ' ;
44
55const MODAL_A = 'modal_a' ;
66const MODAL_B = 'modal_b' ;
77
88const DEFAULT_TITLE = 'Default title' ;
99
10- export default class ViewA extends Component {
10+ class SimpleUsage extends Component {
1111 constructor ( props ) {
1212 super ( props ) ;
1313 this . state = {
@@ -22,7 +22,12 @@ export default class ViewA extends Component {
2222 this . handleModalCloseRequest ( ) ;
2323 return ;
2424 }
25- this . setState ( { ...this . state , currentModal : key , title1 : DEFAULT_TITLE } ) ;
25+
26+ this . setState ( {
27+ ...this . state ,
28+ currentModal : key ,
29+ title1 : DEFAULT_TITLE
30+ } ) ;
2631 }
2732
2833 handleModalCloseRequest = ( ) => {
@@ -34,7 +39,7 @@ export default class ViewA extends Component {
3439 } ) ;
3540 }
3641
37- handleInputChange = ( e ) => {
42+ handleInputChange = e => {
3843 let text = e . target . value ;
3944 if ( text == '' ) {
4045 text = DEFAULT_TITLE ;
@@ -47,13 +52,16 @@ export default class ViewA extends Component {
4752 this . heading && ( this . heading . style . color = '#F00' ) ;
4853 }
4954
55+ headingRef = h1 => this . heading = h1 ;
56+
5057 render ( ) {
5158 const { currentModal } = this . state ;
59+
5260 return (
5361 < div >
5462 < button onClick = { this . toggleModal ( MODAL_A ) } > Open Modal A</ button >
5563 < button onClick = { this . toggleModal ( MODAL_B ) } > Open Modal B</ button >
56- < ModalA
64+ < MyModal
5765 title = { this . state . title1 }
5866 isOpen = { currentModal == MODAL_A }
5967 onAfterOpen = { this . handleOnAfterOpenModal }
@@ -72,12 +80,17 @@ export default class ViewA extends Component {
7280 isOpen = { currentModal == MODAL_B }
7381 onAfterOpen = { this . handleOnAfterOpenModal }
7482 onRequestClose = { this . toggleModal ( MODAL_B ) } >
75- < h1 id = "heading" ref = { h1 => this . heading = h1 } > This is the modal 2!</ h1 >
83+ < h1 id = "heading" ref = { headingRef } > This is the modal 2!</ h1 >
7684 < div id = "fulldescription" tabIndex = "0" role = "document" >
7785 < p > This is a description of what it does: nothing :)</ p >
78- </ div >
86+ </ div > p
7987 </ Modal >
8088 </ div >
8189 ) ;
8290 }
8391}
92+
93+ export default {
94+ label : "#1. Working with one modal at a time." ,
95+ app : SimpleUsage
96+ } ;
0 commit comments