@@ -17,6 +17,7 @@ import {
1717 PanResponder ,
1818 PanResponderGestureState ,
1919 GestureResponderEvent ,
20+ EmitterSubscription ,
2021} from 'react-native' ;
2122import { Navigation , Layout } from 'react-native-navigation' ;
2223/* Utils - Project Utilities */
@@ -171,6 +172,7 @@ class RNNDrawer {
171172 private unsubscribeDismissDrawer ! : ( ) => void ;
172173 private panningStartedPoint : Point = { moveX : 0 , moveY : 0 } ;
173174 private startedFromSideMenu : boolean = false ;
175+ private orientationChangeListener : EmitterSubscription ;
174176
175177 static defaultProps = {
176178 animationOpenTime : 300 ,
@@ -425,7 +427,7 @@ class RNNDrawer {
425427 const { direction, fadeOpacity } = this . props ;
426428
427429 // Adapt the drawer's size on orientation change
428- Dimensions . addEventListener ( 'change' , this . onOrientationChange ) ;
430+ this . orientationChangeListener = Dimensions . addEventListener ( 'change' , this . onOrientationChange ) ;
429431
430432 // Executes when the side of the screen interaction starts
431433 this . unsubscribeSwipeStart = listen ( 'SWIPE_START' , ( value : Point ) => {
@@ -562,7 +564,7 @@ class RNNDrawer {
562564 * Removes all the listenrs from this component
563565 */
564566 removeListeners ( ) {
565- Dimensions . removeEventListener ( 'change' , this . onOrientationChange ) ;
567+ if ( this . orientationChangeListener ) this . orientationChangeListener . remove ( ) ;
566568 if ( this . unsubscribeSwipeStart ) this . unsubscribeSwipeStart ( ) ;
567569 if ( this . unsubscribeSwipeMove ) this . unsubscribeSwipeMove ( ) ;
568570 if ( this . unsubscribeSwipeEnd ) this . unsubscribeSwipeEnd ( ) ;
0 commit comments