@@ -17,6 +17,7 @@ import {
17
17
PanResponder ,
18
18
PanResponderGestureState ,
19
19
GestureResponderEvent ,
20
+ EmitterSubscription ,
20
21
} from 'react-native' ;
21
22
import { Navigation , Layout } from 'react-native-navigation' ;
22
23
/* Utils - Project Utilities */
@@ -171,6 +172,7 @@ class RNNDrawer {
171
172
private unsubscribeDismissDrawer ! : ( ) => void ;
172
173
private panningStartedPoint : Point = { moveX : 0 , moveY : 0 } ;
173
174
private startedFromSideMenu : boolean = false ;
175
+ private orientationChangeListener : EmitterSubscription ;
174
176
175
177
static defaultProps = {
176
178
animationOpenTime : 300 ,
@@ -425,7 +427,7 @@ class RNNDrawer {
425
427
const { direction, fadeOpacity } = this . props ;
426
428
427
429
// Adapt the drawer's size on orientation change
428
- Dimensions . addEventListener ( 'change' , this . onOrientationChange ) ;
430
+ this . orientationChangeListener = Dimensions . addEventListener ( 'change' , this . onOrientationChange ) ;
429
431
430
432
// Executes when the side of the screen interaction starts
431
433
this . unsubscribeSwipeStart = listen ( 'SWIPE_START' , ( value : Point ) => {
@@ -562,7 +564,7 @@ class RNNDrawer {
562
564
* Removes all the listenrs from this component
563
565
*/
564
566
removeListeners ( ) {
565
- Dimensions . removeEventListener ( 'change' , this . onOrientationChange ) ;
567
+ if ( this . orientationChangeListener ) this . orientationChangeListener . remove ( ) ;
566
568
if ( this . unsubscribeSwipeStart ) this . unsubscribeSwipeStart ( ) ;
567
569
if ( this . unsubscribeSwipeMove ) this . unsubscribeSwipeMove ( ) ;
568
570
if ( this . unsubscribeSwipeEnd ) this . unsubscribeSwipeEnd ( ) ;
0 commit comments