Skip to content

Commit

Permalink
get rid of crashes on remove the listener (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
therobertgrigorian authored Oct 3, 2022
1 parent 572d39b commit 97742c2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Swiper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { PanResponder, Text, View, Dimensions, Animated } from 'react-native'
import { PanResponder, Text, View, Dimensions, Animated, InteractionManager } from 'react-native'
import PropTypes from 'prop-types'
import isEqual from 'lodash/isEqual'

Expand Down Expand Up @@ -82,9 +82,11 @@ class Swiper extends Component {

componentWillUnmount = () => {
this._mounted = false
this.state.pan.x.removeAllListeners()
this.state.pan.y.removeAllListeners()
this.dimensionsChangeSubscription.remove()
InteractionManager.runAfterInteractions(() => {
this.state.pan.x.removeAllListeners()
this.state.pan.y.removeAllListeners()
this.dimensionsChangeSubscription?.remove()
})
}

getCardStyle = () => {
Expand Down

0 comments on commit 97742c2

Please sign in to comment.