alexbrillant / react-native-deck-swiper

tinder like react-native deck swiper
ISC License
1.57k stars 464 forks source link

TypeError: undefined is not an object (evaluating '_this.dimensionsChangeSubscription.remove') #388

Open RuzenDev opened 2 years ago

RuzenDev commented 2 years ago

Hey!

Thank you very much for this amazing library.

I sometimes have this warning TypeError: undefined is not an object (evaluating '_this.dimensionsChangeSubscription.remove')

<View
        style={{
          flex: 1,
          position: "absolute",
          height: Dimensions.get("screen").height,
          width: Dimensions.get("screen").width,
          backgroundColor: "transparent",
          marginTop: 50,
          alignContent: "center",
          alignSelf: "center",
          justifyContent: "center",
          zIndex: 9999
        }}>
        <Swiper
          containerStyle={{
            backgroundColor: "transparent",
            width: "100%",
            marginTop: 20
          }}
          disableBottomSwipe
          disableTopSwipe
          onSwiped={this.onSwiped}
          onSwipedRight={this.onSwipedRight}
          onSwipedLeft={this.onSwipedLeft}
          onSwipedAll={this.onSwipedAll}
          cards={this.props.timelineBooks}
          stackSize={3}
          renderCard={(card: {
            isbn: React.Key | null | undefined
            book: { imageUrl: any }
          }) => {
            return (
              <View
                key={card.isbn}
                style={{
                  marginTop: 20,
                  height: Dimensions.get("window").width * 0.9,
                  width: Dimensions.get("window").width * 0.6,
                  alignContent: "center",
                  alignSelf: "center",
                  justifyContent: "center"
                }}>
                <DropShadow
                  style={{
                    shadowColor: "#000",
                    shadowOffset: {
                      width: 2,
                      height: 5
                    },
                    shadowOpacity: 0.4,
                    shadowRadius: 5
                  }}>
                  <FastImage
                    style={styles.bookImage}
                    source={
                      card.book.imageUrl
                        ? {
                            uri: card.book.imageUrl,
                            priority: FastImage.priority.normal,
                            cache: FastImage.cacheControl.immutable
                          }
                        : appearanceMode == "dark"
                        ? require("../../../../../assets/noImage_dark.png")
                        : require("../../../../../assets/noImage_light.png")
                    }
                    resizeMode="contain">
                  </FastImage>
                </DropShadow>
              </View>