diff --git a/Swiper.js b/Swiper.js index a93ec1c0..43b67eac 100644 --- a/Swiper.js +++ b/Swiper.js @@ -80,13 +80,15 @@ class Swiper extends Component { return propsChanged || stateChanged } + componentWillUnmountAfterInteractions = () => { + this.state.pan.x.removeAllListeners() + this.state.pan.y.removeAllListeners() + this.dimensionsChangeSubscription?.remove() + } + componentWillUnmount = () => { - this._mounted = false - InteractionManager.runAfterInteractions(() => { - this.state.pan.x.removeAllListeners() - this.state.pan.y.removeAllListeners() - this.dimensionsChangeSubscription?.remove() - }) + this._mounted = false; + InteractionManager.runAfterInteractions(componentWillUnmountAfterInteractions.bind(this)); } getCardStyle = () => { diff --git a/index.d.ts b/index.d.ts index 79709125..1ef616e3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -38,7 +38,7 @@ declare module 'react-native-deck-swiper' { onSwipedLeft?: (cardIndex: number) => void; onSwipedRight?: (cardIndex: number) => void; onSwipedTop?: (cardIndex: number) => void; - onSwiping?: () => void; + onSwiping?: (x: number, y: number) => void; onTapCard?: (cardIndex: number) => void; onTapCardDeadZone?: number; outputCardOpacityRangeX?: [number, number, number, number, number]; diff --git a/package.json b/package.json index c9b91c73..d0ddffd3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-deck-swiper", - "version": "2.0.9", + "version": "2.0.10", "description": "Awesome tinder like card swiper for react-native. Highly Customizable!", "main": "index.js", "scripts": {