1
1
import 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 ' ;
4
4
5
5
const MODAL_A = 'modal_a' ;
6
6
const MODAL_B = 'modal_b' ;
7
7
8
8
const DEFAULT_TITLE = 'Default title' ;
9
9
10
- export default class ViewA extends Component {
10
+ class SimpleUsage extends Component {
11
11
constructor ( props ) {
12
12
super ( props ) ;
13
13
this . state = {
@@ -22,7 +22,12 @@ export default class ViewA extends Component {
22
22
this . handleModalCloseRequest ( ) ;
23
23
return ;
24
24
}
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
+ } ) ;
26
31
}
27
32
28
33
handleModalCloseRequest = ( ) => {
@@ -34,7 +39,7 @@ export default class ViewA extends Component {
34
39
} ) ;
35
40
}
36
41
37
- handleInputChange = ( e ) => {
42
+ handleInputChange = e => {
38
43
let text = e . target . value ;
39
44
if ( text == '' ) {
40
45
text = DEFAULT_TITLE ;
@@ -47,13 +52,16 @@ export default class ViewA extends Component {
47
52
this . heading && ( this . heading . style . color = '#F00' ) ;
48
53
}
49
54
55
+ headingRef = h1 => this . heading = h1 ;
56
+
50
57
render ( ) {
51
58
const { currentModal } = this . state ;
59
+
52
60
return (
53
61
< div >
54
62
< button onClick = { this . toggleModal ( MODAL_A ) } > Open Modal A</ button >
55
63
< button onClick = { this . toggleModal ( MODAL_B ) } > Open Modal B</ button >
56
- < ModalA
64
+ < MyModal
57
65
title = { this . state . title1 }
58
66
isOpen = { currentModal == MODAL_A }
59
67
onAfterOpen = { this . handleOnAfterOpenModal }
@@ -72,12 +80,17 @@ export default class ViewA extends Component {
72
80
isOpen = { currentModal == MODAL_B }
73
81
onAfterOpen = { this . handleOnAfterOpenModal }
74
82
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 >
76
84
< div id = "fulldescription" tabIndex = "0" role = "document" >
77
85
< p > This is a description of what it does: nothing :)</ p >
78
- </ div >
86
+ </ div > p
79
87
</ Modal >
80
88
</ div >
81
89
) ;
82
90
}
83
91
}
92
+
93
+ export default {
94
+ label : "#1. Working with one modal at a time." ,
95
+ app : SimpleUsage
96
+ } ;
0 commit comments