@@ -35,12 +35,10 @@ export const createOverlayComponent = <
35
35
forwardedRef ?: React . ForwardedRef < OverlayType > ;
36
36
} ;
37
37
38
- let isDismissing = false ;
39
-
40
38
class Overlay extends React . Component < Props > {
41
39
overlay ?: OverlayType ;
42
40
el ! : HTMLDivElement ;
43
-
41
+ isDismissing = false ;
44
42
constructor ( props : Props ) {
45
43
super ( props ) ;
46
44
if ( typeof document !== 'undefined' ) {
@@ -75,7 +73,7 @@ export const createOverlayComponent = <
75
73
shouldComponentUpdate ( nextProps : Props ) {
76
74
// Check if the overlay component is about to dismiss
77
75
if ( this . overlay && nextProps . isOpen !== this . props . isOpen && nextProps . isOpen === false ) {
78
- isDismissing = true ;
76
+ this . isDismissing = true ;
79
77
}
80
78
81
79
return true ;
@@ -91,7 +89,7 @@ export const createOverlayComponent = <
91
89
}
92
90
if ( this . overlay && prevProps . isOpen !== this . props . isOpen && this . props . isOpen === false ) {
93
91
await this . overlay . dismiss ( ) ;
94
- isDismissing = false ;
92
+ this . isDismissing = false ;
95
93
96
94
/**
97
95
* Now that the overlay is dismissed
@@ -142,7 +140,7 @@ export const createOverlayComponent = <
142
140
* overlay is dismissing otherwise component
143
141
* will be hidden before animation is done.
144
142
*/
145
- return ReactDOM . createPortal ( this . props . isOpen || isDismissing ? this . props . children : null , this . el ) ;
143
+ return ReactDOM . createPortal ( this . props . isOpen || this . isDismissing ? this . props . children : null , this . el ) ;
146
144
}
147
145
}
148
146
0 commit comments