alexbrillant / react-native-deck-swiper

tinder like react-native deck swiper
ISC License
1.56k stars 465 forks source link

allSwipedCheck is undefined error #290

Open adriandarian opened 4 years ago

adriandarian commented 4 years ago

I cloned a fresh version of the repo and currently on version ^v1.6.7. I came across a bug where the allSwipedCheck was undefined because in the codebase in the incrementCardIndex() there was a code snippet like this:

allSwipedCheck = () => newCardIndex === this.state.cards.length;

However, the variable is never initialized or declared or even defined prior. So I checked if it was used anywhere else and noticed that it is only used for the 2 if statements right below the assignment.

Solution: Remove the assignment and place the condition into both if statements.

adriandarian commented 4 years ago

This also Fixes #182

adriandarian commented 4 years ago

I suppose you can also just add a let in front of the variable...

let allSwipedCheck = () => newCardIndex === this.state.cards.length
haveamission commented 4 years ago

Yep, this fixed the same issue on my cards