diff --git a/node_modules/react-native-modal-popover/lib/Popover.js b/node_modules/react-native-modal-popover/lib/Popover.js index ddd7fb2..742105f 100644 --- a/node_modules/react-native-modal-popover/lib/Popover.js +++ b/node_modules/react-native-modal-popover/lib/Popover.js @@ -203,10 +203,12 @@ class Popover extends React.PureComponent { this.onOrientationChange(); } componentDidMount() { - react_native_1.Dimensions.addEventListener('change', this.onOrientationChange); + this.eventSub = react_native_1.Dimensions.addEventListener('change', this.onOrientationChange); } componentWillUnmount() { - react_native_1.Dimensions.removeEventListener('change', this.onOrientationChange); + if(this.eventSub){ + this.eventSub.remove(); + } } UNSAFE_componentWillReceiveProps(nextProps) { const willBeVisible = nextProps.visible; diff --git a/node_modules/react-native-modal-popover/lib/PopoverController.js b/node_modules/react-native-modal-popover/lib/PopoverController.js index 005c07f..71e84f4 100644 --- a/node_modules/react-native-modal-popover/lib/PopoverController.js +++ b/node_modules/react-native-modal-popover/lib/PopoverController.js @@ -62,10 +62,12 @@ class PopoverController extends React.PureComponent { this.closePopover = () => this.setState({ showPopover: false }); } componentDidMount() { - react_native_1.Dimensions.addEventListener('change', this.onOrientationChange); + this.eventSub = react_native_1.Dimensions.addEventListener('change', this.onOrientationChange); } componentWillUnmount() { - react_native_1.Dimensions.removeEventListener('change', this.onOrientationChange); + if(this.eventSub){ + this.eventSub.remove(); + } } render() { return this.props.children({ diff --git a/node_modules/react-native-modal-popover/lib/PopoverTouchable.js b/node_modules/react-native-modal-popover/lib/PopoverTouchable.js index 09c205f..4291920 100644 --- a/node_modules/react-native-modal-popover/lib/PopoverTouchable.js +++ b/node_modules/react-native-modal-popover/lib/PopoverTouchable.js @@ -58,10 +58,12 @@ class PopoverTouchable extends React.PureComponent { }; } componentDidMount() { - react_native_1.Dimensions.addEventListener('change', this.onOrientationChange); + this.eventSub = react_native_1.Dimensions.addEventListener('change', this.onOrientationChange); } componentWillUnmount() { - react_native_1.Dimensions.removeEventListener('change', this.onOrientationChange); + if(this.eventSub){ + this.eventSub.remove(); + } } render() { const children = React.Children.toArray(this.props.children); diff --git a/node_modules/react-native-modal-popover/lib/usePopover.js b/node_modules/react-native-modal-popover/lib/usePopover.js index 75cc72a..a2ce0cd 100644 --- a/node_modules/react-native-modal-popover/lib/usePopover.js +++ b/node_modules/react-native-modal-popover/lib/usePopover.js @@ -45,9 +45,11 @@ function usePopover(calculateStatusBar = false) { requestAnimationFrame(openPopover); } }; - react_native_1.Dimensions.addEventListener('change', onOrientationChange); + const eventSub = react_native_1.Dimensions.addEventListener('change', onOrientationChange); return () => { - react_native_1.Dimensions.removeEventListener('change', onOrientationChange); + if(eventSub){ + eventSub.remove(); + } }; }, [showPopover, openPopover]); return result; diff --git a/node_modules/react-native-modal-popover/src/Popover.tsx b/node_modules/react-native-modal-popover/src/Popover.tsx index 87a449c..fb288e2 100644 --- a/node_modules/react-native-modal-popover/src/Popover.tsx +++ b/node_modules/react-native-modal-popover/src/Popover.tsx @@ -171,11 +171,13 @@ export class Popover extends React.PureComponent { } componentDidMount() { - Dimensions.addEventListener('change', this.onOrientationChange); + this.eventSub = Dimensions.addEventListener('change', this.onOrientationChange); } componentWillUnmount() { - Dimensions.removeEventListener('change', this.onOrientationChange); + if(this.eventSub){ + this.eventSub.remove() + } } private computeGeometry = ( diff --git a/node_modules/react-native-modal-popover/src/PopoverController.tsx b/node_modules/react-native-modal-popover/src/PopoverController.tsx index a5e6e32..6d50cd8 100644 --- a/node_modules/react-native-modal-popover/src/PopoverController.tsx +++ b/node_modules/react-native-modal-popover/src/PopoverController.tsx @@ -39,11 +39,13 @@ export class PopoverController extends React.PureComponent { }; componentDidMount() { - Dimensions.addEventListener('change', this.onOrientationChange); + this.eventSub = Dimensions.addEventListener('change', this.onOrientationChange); } componentWillUnmount() { - Dimensions.removeEventListener('change', this.onOrientationChange); + if(this.eventSub){ + this.eventSub.remove(); + } } private onOrientationChange = () => { diff --git a/node_modules/react-native-modal-popover/src/PopoverTouchable.tsx b/node_modules/react-native-modal-popover/src/PopoverTouchable.tsx index cbb7526..a43caf5 100644 --- a/node_modules/react-native-modal-popover/src/PopoverTouchable.tsx +++ b/node_modules/react-native-modal-popover/src/PopoverTouchable.tsx @@ -18,6 +18,7 @@ export interface State { } export class PopoverTouchable extends React.PureComponent { + static propTypes = { onPopoverDisplayed: PropTypes.func, }; @@ -33,11 +34,13 @@ export class PopoverTouchable extends React.PureComponent { } componentDidMount() { - Dimensions.addEventListener('change', this.onOrientationChange); + this.eventSub = Dimensions.addEventListener('change', this.onOrientationChange); } componentWillUnmount() { - Dimensions.removeEventListener('change', this.onOrientationChange); + if(this.eventSub){ + this.eventSub.remove(); + } } private onOrientationChange = () => { diff --git a/node_modules/react-native-modal-popover/src/usePopover.ts b/node_modules/react-native-modal-popover/src/usePopover.ts index 2d05b78..7e68dbf 100644 --- a/node_modules/react-native-modal-popover/src/usePopover.ts +++ b/node_modules/react-native-modal-popover/src/usePopover.ts @@ -78,9 +78,11 @@ export function usePopover(calculateStatusBar = false): UsePopoverHook { requestAnimationFrame(openPopover); } }; - Dimensions.addEventListener('change', onOrientationChange); + const eventSub = Dimensions.addEventListener('change', onOrientationChange); return () => { - Dimensions.removeEventListener('change', onOrientationChange); + if(eventSub){ + eventSub.remove(); + } }; }, [showPopover, openPopover]);