question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow for disableBottomSwipe (and others) to be functions

See original GitHub issue

It would be useful to allow for disableBottomSwipe and the other similar props to be booleans or functions that return a boolean, to allow clients to enable or disable swipe directions per-card.

It might look something like:

<Swiper
    cards={ [ /* ... */ ] }
    disableTopSwipe={
        card => card.canSwipeUp
    } />

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
webraptorcommented, Mar 18, 2019
<Swiper
            ref={swiper => {
              this.swiper = swiper
            }}
            renderCard={this.renderCard}
            cards={cards}
            cardIndex={cardIndex}
            disableBottomSwipe={cards[cardIndex].bottomDisabled}
            stackSize= {3}>
</Swiper>

How does your state management look like? Unless your cardIndex changes, it will always be 0 for instance. So no matter how many times you swipe, cards[cardIndex].bottomDisabled will be cards[0].bottomDisabled, which is disabled. As you swipe the swiper keeps track of your index internally and renders the proper cards, but since cardIndex isn’t updated within the parent component, it will stay to what you initialise the state with (probably 0), resulting in your error.

1reaction
webraptorcommented, Nov 20, 2017
const {cards , cardIndex } = this.state; // or this.props, whatever you got going on
// [... extra code, in render() lets say]
<Swiper
  disableBottomSwipe={cards[cardIndex].bottomDisabled}
  cards={cards}
  cardIndex={cardIndex}
/>

PS: didn’t put all props for the Swiper. bottomDisabled is a bool prop within the card object part of the cards array passed onto the Swiper… If it’s missing it automatically goes to false.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-deck-swiper/README.md at master - GitHub
Swipe animation props ; swipeAnimationDuration, number, duration of the swipe animation ; disableBottomSwipe, bool, disable bottom swipe ; disableLeftSwipe, bool ...
Read more >
How to Get data from react native-deck-swiper when swiped
I have written a function that opens a web browser. PLEASE CAN SOMEONE HELP ME. //SWIPPER <SafeAreaView style={{ flex: 1 }}> {/* < ......
Read more >
starodubenko/react-native-card-stack-swiper - npm package
disableBottomSwipe, bool, disable bottom swipe, false ... onSwipeStart, func, function to be called when a card swipe starts.
Read more >
Tinder like React Native Card Stack Swiper - Morioh
React Native allows developers to develop mobile apps that have compatibility with Android, iOS & other operating systems. Due to the features like ......
Read more >
[Solved]-How to pass dynamic ref in react-native-deck-swiper ...
function MySwiper({item}) { const swiperRef = useRef(null); const [isSwipedAll, ... API_URL_DEV}/copernic/vote/add`, requestOptions ); let json = await ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found