alexbrillant / react-native-deck-swiper

tinder like react-native deck swiper
ISC License
1.55k stars 461 forks source link

Send prop to renderCard #316

Open uguzdev opened 4 years ago

uguzdev commented 4 years ago

Hello, I have a button in bottom the photo. Can I disabled the button when swipe enabled.

Example

          dragStart={() => setIsClickable(false)}
          dragEnd={() => setIsClickable(true)}
          renderCard={(card) => <UserCard clickable={isClickable} user={card} />}

in UserCard.js <TouchableOpacity disabled={!clickable} />

webraptor commented 4 years ago

Unfortunately no, not unless you fork and edit the library itself. The cards do not re-render unless their content change, so even if your parent state changes (isClickable prop turns between true and false) the cards will not change, they won't get re-rendered so your button will preserve the original state.

Also, take into consideration that by adding more props that trigger re-renders of the cards, the performance of the swiper will degrade.

jacquesdev commented 4 years ago

Please see here: https://github.com/alexbrillant/react-native-deck-swiper/issues/324