tarasvakulka / react-native-cards-swipe

Card Stack Swiper implemented with Reanimated 2 and React Native Gesture Handler
MIT License
57 stars 15 forks source link

Component breaks when length of cards array is 1 #8

Closed elboboua closed 2 years ago

elboboua commented 2 years ago

I believe there needs to be an extra check in this condition to ensure that the card length is long enough to handle a secondIndex. It is breaking when the length of the cards array is equal to 1.

https://github.com/tarasvakulka/react-native-cards-swipe/blob/0673b136104e77e7de2b6a82fe3b7c4e9e3530cb/src/components/CardsSwipe/index.tsx#L269

In some cases there will be only one card and this code will break. As a temporary fix, I included the following code in the renderCard function:

(card) => {
    if (!card) return;
    // my own render component
}
tarasvakulka commented 2 years ago

Thanks for report, fixed in v1.2.1